Android system compilation encountered several. Mk doubts.

Source: Internet
Author: User

In the Android4.2 source code BUILD/PRDUCT_CONFIG.MK inside encountered a few doubts:

# Convert A short name as "sooner" into the path to the product# file defining that product. #INTERNAL_PRODUCT: = $ (call Resolve-short-product-name, $ (target_product)) Ifneq ($ (current_product_makefile), $ (internal_product)) $ (Error Product_Name inconsistent in $ (current_product_makefile) and $ (internal_product)) Endifcurrent_product_makefile: =all _product_makefiles: =all_product_configs: =# Find The device, the this product, maps to. Target_device: = $ (products.$ (internal_product). Product_device)

According to the truth makefile in reading the Product_config.mk file, Target_device first feeling should be understood I a synthetic variable, of course, this is the principle of makefile. But it's not found here, why? Because a node_fns.mk file was introduced. The role of the file is similar to the requirement that the content of the start should be handled according to its logic, as if it were defined as a macro form, then the variable processing will actually become another processing mode:

For example here is the actual:

Internal_product = Device/softwinner/fiber-3g/fiber_3g.mk

Target_device = fiber-3g

To tell the truth himself is not very understanding of the role of NODE_FNS.MK, he understood as a definition of a lot of macros in the header file it.

Watching the old Luo's Android trip, the harvest is very right. The substance of the above is $ (products.$ (internal_product). Product_device) is a completely new variable. By analyzing the contents of the androidproducts.mk and then adding different _product_var_list, you can generate new variables that are generated based on different products that you customize. The following variable becomes the Target_device mentioned above, the essence of which is defined in the ANDROIDPRODUCTS.MK:

# Overridesproduct_brand  : = softwinnerproduct_name   : = fiber_3gproduct_device: = Fiber-3gproduct_model  : = Softwinn
products.build/target/product/full.mk.product_name: = fiber_3g products.build/target /product/full.mk.product_device: = fiber-3g 
_product_var_list: =     product_name     product_model     product_locales     product_aapt_config     Product _aapt_pref_config     product_packages     product_packages_debug     Product_packages_eng     PRODUCT_ Packages_tests     product_device     product_manufacturer     product_brand     product_property_overrides     Product_default_property_overrides     Product_characteristics     product_copy_files     product_ota_public_keys     Product_extra_recovery_keys     product_package_overlays     Device_package_overlays     product_tags     product_sdk_addon_name     product_sdk_addon_copy_files     Product_sdk_addon_copy_modules     product_sdk_addon_doc_modules     product_default_wifi_channels     Product_default_dev_certificate     product_restrict_vendor_files     product_vendor_kernel_headers     Product_factory_ramdisk_modules     Product_factory_bundle_modules


For. mk files in an Android system, they can be called after source/build/envsetup.sh. Like what:

function Get_build_var () {    t=$ (gettop)    if [! "$T"]; Then        echo "couldn ' t locate the top of the tree.  Try setting TOP. ">&2        return    fi    called_from_setup=true Build_system=build/core make       -- No-print-directory-c "$T"-F build/core/config.mk dumpvar-$1}

The script function will be lunch selected, Chenk products, and further perform get_build_var target_device function processing. The essence of this is to perform a make operation. It looks exactly like a system-compiled make-j8. It's just that he performed only CONFIG.MK configuration-related content. The envsetup.mk is executed in turn, to Product_config.mk, and finally the contents of the Target_device variable are obtained.

6. $DEVICE the process of generating variables is actually the path where the file fiber-3g is located:first, all device and vendor vendorsetup.sh are added through the source envsetup.sh, and the combo integration is completed. The lunch function selects the corresponding platform and sets all the environment variables required for compilation to be done using the following function:#设置环境变量
Set_stuff_for_environment
#打印最终的配置信息
Printconfig
set_stuff_for_environment setpath function, the function will export many environment paths for subsequent script functions to execute the call There are imports that include export device:tdevice=$ (Get_build_var target_device)
Export device= $T/device/*/$tdeviceThe following custom Android compilation items and create product profile, board board level profile:7 The lunch process determines the contents of target_product = fiber_3g;
8target_device=fiber-3g, inbuild/core/product_config.mkin accordance withProduct_device to determine. by traversing the. mk file that is introduced in ANDROIDPRODUCTS.MK in all device directories, such as this refers to fiber_3g.mk. match the lookup to the corresponding androidproducts.mk by target_product. And Product_device was identified as fiber-3g in Fiber_3g.mk. Through the macro action of node_fns.mk, and then determinethe content of Target_device is fiber-3g.
The role of 9.BOARDCONFIG.MK. Build/core/config.mk to decide. by traversing device/*/$ (Target_device)/boardconfig.mk to complete


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.