How to identify target_product in Android makefile

Source: Internet
Author: User

http://blog.csdn.net/stevenliyong/article/details/5285334

Today there is time to underestimate the Android makefile, and finally a little understanding of how the Android compiler system through the environment variable target_product to decide to compile custom PRODUCT.

First, compiling Android code is typically used:

# Make Showcommands

This is actually equivalent to the complete command below (see build/core/envsetup.mk for details)

# target_arch=arm Target_product=generic target_build_type=release make Showcommands

Visible, by default the compilation system considers target_product to be generic

So how do you compile a specific product for Android?

This requires a look at how Android makefile resolves environment variable target_product.

The reference relationship for Android Makefile is like this

Makefile, Build/core/main.mk, Build/core/config.mk, Build/core/envsetup.mk, build/core/product_ Config.mk

Compiling the system in BUILD/CORE/PRODUCT_CONFIG.MK first calls the function Get-all-product-makefiles defined in BUILD/CORE/PRODUCT.MK to

Traverse the entire vendor subdirectory, find vendor under all androidproducts.mk, different sub-directories androidproducts.mk defined different product_name, product_device and other information, (We can also export all product information when the console compiles by opening the #$ (dump-products) statement in build/core/product_config.mk), and then build/core/product_ CONFIG.MK calls Resolve-short-product-name to assign Product_device the Target_device defined in target_product matching androidproducts.mk.

With this target_device, and then back to Build/core/config.mk,

will include $ (target_devcie)/boardconfig.mk

BOARD_CONFIG_MK: =/
$ (Strip $ (wildcard/
$ (Src_target_dir)/board/$ (target_device)/boardconfig.mk/
vendor/*/$ (Target_device)/boardconfig.mk/
))

Include $ (BOARD_CONFIG_MK)

And this configuration file BOARDCONFIG.MK determines the target system compiler properties, such as using ALSA or not generic_audio, etc.

In addition here Target_device macro also decided Target_device_dir, because Target_device_dir take is the above mentioned boardconfig.mk path.

Target_device_dir: = $ (Patsubst%/,%,$ (DIR $ (BOARD_CONFIG_MK)))

Of course the Android OB target output is also determined by Target_device, see BUILD/CORE/ENVSETUP.MK

Target_out_root_release: = $ (Out_dir)/target
Target_out_root_debug: = $ (Debug_out_dir)/target
Target_out_root: = $ (target_out_root_$ (Target_build_type))

Target_product_out_root: = $ (target_out_root)/product

Product_out: = $ (target_product_out_root)/$ (Target_device)

Back to Build/core/main.mk, one of the things that the compilation system does next is to traverse through all the word directories, find all the android.mk files, and include these android.mk files in

#
# Typical build; Include any android.mk files we can find.
#

Subdir_makefiles: =/
$ (Shell build/tools/findleaves.py--prune=out--prune=.repo--prune=.git $ (subdirs) android.mk)

Include $ (subdir_makefiles)

We'll see it again.

./build/target/board/android.mk

, yes, it references the

Include $ (target_device_dir)/androidboard.mk

By the definition of the above target_device_dir, this goes again into the

Vendor the directory under Target_device, this MK file defines the specific product to compile and install the app and script.

How to identify target_product in Android makefile

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.