Import-nodes process for product products during the initialization of Android system compilation environment

Source: Internet
Author: User
Tags define get

Starting with the run make-f config,mk file, config,mk as the current makefile file. will be make parsing, general make parsing makefile file flow is first loaded in the various other MK files included, the same time in the loading process will initialize their own defined variables, similar to precompilation, after the completion of various initialization, determine the target and dependencies, Finally run the target output action.

There are several MK files in config.mk that require include. Focus on product-related envsteup.mk

The envsteup.mk will include PRODUCT_CONFIG.MK. Start extracting the product-related models that are currently configured in the system.

1. Product Import Portal

$ (call Import-products, $ (call get-all-product-makefiles))

You can see that the variable is implemented by a macro definition in the Product.mk file of the previous include.

Define Get-all-product-makefiles $ (call get-product-makefiles,$ (_find-android-products-files)) endef

You can use define to define a function in the makefile file. Or can be understood as a macro, assuming that you need to pass in the argument when calling your own defined function. It is generally necessary to use the call function to indirectly invoke the function name. Otherwise, it can be directly called by the function name (usually without the same name variable). Handled in a functional manner), called Get-all-product-makefiles as described above.


2. Get-all-product-makefiles

The get-all-product-makefiles process is similar, first calling the _find-android-products-files function, The purpose of this function is to traverse all the androidproduct.mk files in the system and return the result as a space-delimited variable as a return value

Define _find-android-products-files $ (Shell test-d device && find-l device-maxdepth 6-name Androidproduc TS.M    k)   $ (Shell test-d vendor && Find vendor-maxdepth 6-name androidproducts.mk    )  33< c5/>$ (src_target_dir)/product/androidproducts.mk endef


3 Get-product-makefiles processing androidproducts.mk, the latter with $ (1) as the input of the parameters

Define Get-product-makefiles $ (sort $ (   foreach f,$ (1),     $ (eval product_makefiles: =)  45     $ (eval local_dir: = $ (Patsubst%/,%,$ (DIR $ (f))) $  (     eval include $ (f)) $ (     product_makefiles )    (eval   product_makefiles: =) $   (eval local_dir: =)  51  
This function roughly deals with the For Loop F, which is the androidproduct,mk of the previous find. It is also used as the Mk file include. Extract the variables with product_makefiles in them. Each of the ANDROIDPRODUCT.MK

The extracted product_makefiles is returned as a file.

Finally, after the function is processed, the return value structure is roughly the following, and you can see that the result is roughly the relative path that defines the product-related MK related to the top-level folder of the system:

Build/target/product/full.mk.product_name: = Full

Build/target/product/full_x86.mk build/target/product/generic.mk build/target/product/generic_x86.mk Build/target /product/large_emu_hw.mk build/target/product/sdk.mk build/target/product/sdk_x86.mk Build/target/product/vbox_ X86.mk device/asus/grouper/full_grouper.mk device/generic/armv7-a-neon/mini_armv7a_neon.mk device/generic/armv7-a /mini_armv7a.mk device/moto/stingray/full_stingray.mk device/moto/stingray/generic_stingray.mk device/moto/ Stingray/stingray_emu.mk device/moto/wingray/full_wingray.mk device/sample/products/sample_addon.mk device/ Samsung/crespo/full_crespo.mk device/samsung/crespo4g/full_crespo4g.mk device/samsung/maguro/full_maguro.mk Device/samsung/toro/full_toro.mk device/samsung/tuna/full_tuna.mk device/ti/panda/full_panda.mk

4.import-products function

133 Define import-products134 $ (Info ssssssssssssss$ (products)!!!!!!!!!!) 135 $ (Call import-nodes,products,$ (1), $ (_product_var_list)) 136 $ (Info ccccccccccccc$ (Products) a----------AAA) 137 Endef
Here $ (1) represents the return value of the function processed in the above 3. is a list of MK files with product definitions. This return value is processed by Import-nodes:

244 $ (If 245   $ (foreach _in,$ (2), 246     $ (eval _node_import_context: = _nic.$ (1). [ [$ (_in)]) 247     $ (if $ (_include_stack), $ (eval $ (Error assertion FAILED: _include_stack 248                 should is empty here: $ (_include_ stack)),) 249     $ (eval _include_stack: =) $ (call     _import-nodes-inner,$ (_node_import_context), $ (_in), $ (3) ) 251     $ (call move-var-list,$ (_node_import_context). $ (_in), $ (1). $ (_in), $ (3)) 252     $ (eval _node_import_ Context: =) 253     $ (eval $ (1): = $ ($ (1)) $ (_in)) 254     $ (if $ (_include_stack), $ (eval $ (Error assertion FAILED: _includ E_stack 255                 should is empty here: $ (_include_stack))),) (257    ,) 258 endef
The processing of this function is more complex. But the general meaning is based on the path of each MK file, found after each MK file defined in the variable field, such as:

Product_Name: = Fullproduct_device: = Genericproduct_brand: = Androidproduct_model: = Full Android on Emulator
After processing is converted to a completely new variable, the similarity is as follows:

PRODUCT.BUILD/TARGET/PRODUCT/FULL.MK.PRODUCT_NAEM: = Full

In addition, another point needs to be noted. After running the function, the relevant input parameters of $ (2) will be returned and saved to a brand new variable products.

When the variable is probably in the target product check, the Target_device is finally determined. Need to go through for example the following steps:

Internal_product: = $ (Call Resolve-short-product-name, $ (target_product))

Target_device: = $ (products.$ (internal_product). Product_device)

In the call to Resolve-short-product-name (as explained in the previous blog post), the Mk file path in this variable is extracted and a variable name is formed

Product.build/target/product/full.mk.product_naem
For example, the following:

Define _resolve-short-product-name181   $ (eval PN: = $ (Strip $ (1))) 182   $ (eval p: = 183       $ (foreach p,$ ( Products), 184           $ (if $ (the filter $ (PN), $ (products.$ (p)). Product_Name)), 185             $ (p) 186        )) 187    ) 188   $ (eval p: = $ (sort $ (P))) 189   $ (if $ (filter 1,$ (words $ (p))) ,     191 $ (p), $ (     if $ (filter 0,$ (words $ (p))), 192       $ (Error No matches for product "$ (PN)"), 193       $ (erro R Product "$ (PN)" Ambiguous:matches $ (p)) 194     ) \
The PN value passed in here is the target_product of our choice. Only in the whole MK found product_name and target_product consistent, we lunch choose the product is reasonable, the entire system compiler environment initialization is normal. Lay the groundwork for the make/mm, and make sure it is normal, because the subsequent making, MM, and so on will undergo this iterative environment initialization process.






Import-nodes process for product products during the initialization of Android system compilation environment

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.