Re: [android-building] How to adding and removing packages in a custom build

910 views
Skip to first unread message

Magnus Bäck

unread,
Feb 25, 2013, 11:56:26 AM2/25/13
to android-...@googlegroups.com
On Monday, February 25, 2013 at 10:24 EST,
Oliver Hill <olly....@gmail.com> wrote:

> Hey guys, I'm looking into putting together a custom ROM, and I'm
> wondering if there's an easy way to define which packages are made in
> a build. I've set up my own device in /device/mycompany/mydevice, but
> at the moment it's just a copy of an existing device. Which file
> should I look at editing to build only the specific packages that I
> want? I think I need to edit a "Product Definition File" and use
> PRODUCT_PACKAGES and a long list, but I'm not sure which file the
> "product definition file" actually is. (I got that from
> http://www.netmite.com/android/mydroid/development/pdk/docs/build_system.html).

The product definition file is the file in device/mycompany/mydevice
that contains "PRODUCT_NAME := devicename", where 'devicename' is
the first half of the build configuration chosen from the lunch name.
In other words, 'lunch full_yourdevice-eng' means you should be looking
for 'full_yourdevice' being assigned to PRODUCT_NAME.

> Another alternative appears to be editing
> /build/target/product/core.mk, but I don't know whether that will
> affect a single device or all devices.

It will affect all devices that inherit from that pseudo-product.

> It also doesn't seem to have all packages: my test-goal is to build a
> device without a calculator but I can't track down the
> "PRODUCT_PACKAGES += Calculator" line in the /build/target/product
> directory. Could it even be so simple as to put "PRODUCT_ PACKAGES -=
> Calculator" somewhere?

That would only work if put in the same file that adds Calculator
to PRODUCT_PACKAGES. Products are strictly additive, i.e. a product
can't remove a package that's been put in PRODUCT_PACKAGES by a parent
product.

> In sum, I would really appreciate some help in working out how I can
> go about including or excluding packages in a custom device without
> having to do anything to the source code. I'm sure there must be some
> manifest-esque file in the /device/ directory but I can't for the life
> of me find it!

At least on the master branch, Calculator is added to PRODUCT_PACKAGES
in build/target/product/generic_no_telephony.mk. If you don't want it
I believe the only way is to modify that file. If you don't want other
products to be affected you'll have to fork that part of the product
tree.

--
Magnus Bäck
ba...@google.com

Jean-Francois Blanchard-Dionne

unread,
Feb 25, 2013, 12:25:59 PM2/25/13
to android-...@googlegroups.com
I think the best way to do this would be in your overlay folder for your specific device.


--
JF

Magnus Bäck

unread,
Feb 25, 2013, 1:10:32 PM2/25/13
to android-...@googlegroups.com
On Monday, February 25, 2013 at 12:16 EST,
Oliver Hill <olly....@gmail.com> wrote:

> Thanks for the explanation. Would it be possible for me to create a
> .mk file in /build/target/products that only applied to a specific
> device, allowing me finer tuned control over what is included in the
> build? Even if I could I guess that would include core.mk and I
> wouldn't be able to remove packages core.mk had added, and I imagine
> it's not a great idea to overwrite or even remove core.mk.
>
> More generally, what decides which .mk files from
> /build/target/product are used in a build?

Product files have lines like

$(call inherit-product-if-exists, frameworks/base/data/fonts/fonts.mk)
$(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)

that configure the product's parent product(s). Parent products may,
in turn, inherit from yet other products. That's how the tree is built
up. You can probably have a concrete product with no parent product at
all. That would allow you to have complete control over your product
configuration, but you'd obviously have to duplicate a lot of stuff
and your set up would not respond well to upstream changes.

--
Magnus Bäck
ba...@google.com

Magnus Bäck

unread,
Feb 26, 2013, 11:46:45 AM2/26/13
to android-...@googlegroups.com
On Tuesday, February 26, 2013 at 08:47 EST,
Oliver Hill <olly....@gmail.com> wrote:

> Thanks very much. I don't suppose you know where I might find a list
> of packages included by the .mk files in /build/target/product
> (ideally with a short description of what each package does and
> depends on) to assist in working out which packages I want to include,
> and which I need to include?

A module's dependencies should be listed in LOCAL_REQUIRED_MODULES
but that rarely happens AFAIK. I don't think there's any authoritative
table of the available Android modules and how they interact. I know
O'Reilly's Embedded Android book contains at least some stuff.

--
Magnus Bäck
ba...@google.com
Reply all
Reply to author
Forward
0 new messages