Current location - Recipe Complete Network - Complete cookbook of home-style dishes - How to identify TARGET_PRODUCT in Android Makefile?
How to identify TARGET_PRODUCT in Android Makefile?
TARGET_PRODUCT decides to compile the customized product.

First, compiling Android code usually uses:

# Make display commands

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

# target _ arch = armtarget _ product = generic target _ build _ type = release make show command.

As you can see, by default, the compilation system considers TARGET_PRODUCT to be generic.

So how do you compile Android for specific products?

It depends on how Android Makefile parses the environment variable TARGET_PRODUCT.

The reference relationship of Android Makefile is as follows

makefile->; build/core/main . MK-& gt; build/core/config . MK-& gt; build/core/env setup . MK-& gt; Build/Core/Product Configuration. mk

In build/core/product_config.mk, the compiling system first calls the function get-all-product-makefiles defined in build/core/product.mk.

Traverse all subdirectories of vendor and find all AndroidProducts.mk under vendor. Different information such as PRODUCT_NAME, PRODUCT_DEVICE _ device is defined in AndroidProducts.mk under different subdirectories. (We can also let the console output all product information at compile time by opening the #$(dump-products) statement in build/core/product_config.mk). Then build/core/product_config.mk will call resolve-short-product-name to assign the PRODUCT_DEVICE defined in AndroidProducts.mk to the TARGET_PRODUCT to match the TARGET_DEVICE.

With this TARGET_DEVICE, go back to build/core/config.mk,

Will contain $ (target _ devcie)/boardconfig.mk.

board_config_mk := /

$(strip $ (wildcard/

$(SRC _ TARGET _ DIR)/board/$(TARGET _ DEVICE)/board config . MK/

vendor/*/$(TARGET _ DEVICE)/board config . MK/

))

Include $(board_config_mk)

This configuration file BoardConfig.mk determines the compilation properties of the target system, such as using ALSA or not using GENERIC_AUDIO, and so on.

In addition, the TARGET_DEVICE macro also determines the TARGET_DEVICE_DIR here, because the TARGET_DEVICE_DIR takes the path of BoardConfig.mk mentioned above.

Target device directory: = $(patsubst %/,%, $ (directory $(board_config_mk)))

Of course, the Ob target output of Android is also determined by TARGET_DEVICE. See build/core/envsetup.mk.

Target _ Output _ Root _ Release: = $ (Output _ Directory)/Target

Target _ Output _ Root _ Debug: = $ (Debug _ Output _ Directory)/Target

Target Output Root: = $ (Target Output Root _ $ (Target Generation Type))

Target product output root: = $ (target product output root)/product

Product output: = $ (target product output root)/$ (target device)

Back to build/core/main.mk, the next thing for the compilation system is to traverse all word directories, find all the Android.mk files, and include them.

#

# Typical construction; Including any Android.mk file we can find.

#

subdir_makefiles := /

$(shell build/tools/find leaves . py-prune = out-prune =。 repo - prune=。 git $(subdirs) Android.mk)

Include $(subdir_makefiles)

Let's take a look at one of them.

. /build/target/board/Android.mk

By the way, it quotes

Include $ (target device directory)/androidboard.mk.

According to the definition of TARGET_DEVICE_DIR above, it has entered again.

Directory pointed by TARGET_DEVICE under the supplier. This mk file defines that a specific product needs to compile and install an app and a script.