Android system new product customization (1)

Source: Internet
Author: User
Tags define get

<1> configuration process analysis:
Jackie @ Jackie-Host :~ /SVN/vimicro $ ../build/envsetup. Sh
Including device/vimicro/vortex/vendorsetup. Sh
------------------------------------------------------------------
Build/envsetup. Sh ends:
# Execute the contents of any vendorsetup. Sh files we can find.

For f in '/bin/ls vendor/*/vendorsetup. Sh vendor/*/build/vendorsetup. Sh device/*/vendorsetup. Sh 2>/dev/null'

Do
Echo "including $ F"
. $ F

Done

Unset F
------------------------------------------------------------------
Device/vimicro/vortex/vendorsetup. sh:
Add_lunch_combo generic_vortex-userdebug

Add_lunch_combo full_vortex-userdebug // Add a lunch project
------------------------------------------------------------------
Jackie @ Jackie-Host :~ /SVN/vimicro $ lunch // configure lunch

You're building on Linux

Lunch menu... pick a combo:
1. Generic-Eng
2. Simulator
3. generic_vortex-userdebug
4. full_vortex-userdebug

Which wocould you like? [Generic-Eng] 3
-------------------------------------------------------------------
Function lunch ()
{

Local answer
If ["$1"]; then
Answer = $1
Else
Print_lunch_menu
// Print the lunch list
Echo-n "which wowould you like? [Generic-Eng]"
Read answer
..................
# Separate the product in the product-variant model
# Separating the variant of the product-variant model
# Check to see if it is within the range of (User userdebug ENG)
Export target_product = $ Product
Export target_build_variant = $ Variant
Export target_simulator = false
Export target_build_type = release
Printconfig
// Print some major variables and call the relation printconfig ()-> get_build_var ()-> build/CORE/config. mk-> build/CORE/envsetup. mk
}

Function print_lunch_menu ()
{

Local uname = $ (uname)
Echo
Echo "you're building on" $ uname
Echo
Echo "lunch menu... pick a combo :"
Local I = 1
Local choice
For choice in $ {lunch_menu_choices [@]}
Do
Echo "$ I. $ choice"
I = $ ($ I + 1 ))
Done
Echo

}
-------------------------------------------------------------------
Echo at the end of build/CORE/envsetup. mk:
========================================================== ====
Platform_version_codename = REL
Platform_version = 2.3 // envsetup. mk-> version_defaults.mk defines the platform version
Target_product = generic_vortex
Target_build_variant = userdebug
Target_simulator = false // envsetup. mk: When the default value is false, target_product = generic
Target_build_type = release
Target_build_apps = // lunch-> export target_build_apps =
Target_arch = arm.
Host_arch = x86.
Host_ OS = Linux.
Host_build_type = release.
Build_id = grh55 // lunch->...-> envsetup. mk is defined
========================================================== ====
The default macro definition is available in build/buildspec. mk. default.

<2> Android compilation system analysis:
Run make-J2.
Makefile in the top-level directory:
There is only one row: Include build/CORE/Main. mk
Solid is actually compiled from Main. mk.
1 initialization parameter settings:
In Main. mk, after a few variables in the main compilation path are set, go to config. mk:
Build/CORE/Main. mk-> config. mk
-> (0) First, a series of paths of the source file are set, including the path of the header file, library file, service, and API compiled tool.
Example: src_headers: = \...... Src_target_dir: = $ (topdir) Build/target.
-> (1) read the settings of buildspec. mk. Here we can add our own target product information:
Directly edit build/buildspec. mk. Default and move it to the root directory. device/vimicro/vortex/buildspec. mk is the same.

Ifndef target_product
Target_product: = generic_vortex
Endif
2 read product settings:

-> (2) Go to envsetup. mk:
-> Version_defaults.mk defines the platform version.
-> Product_config.mk: include $ (build_system)/product. mk
Get-all-product-makefiles
Product. MK: Define get-all-product-makefiles to traverse the sub-directories of the entire vendor or device and find all androidproducts in the directory of the vendor or device. MK, "product. MK "defines different product_name, product_device, and other information.
---------------------------------------------------------------------
Device/vimicro/vortex/androidproducts. mk contains all the specific "product. mk" files.
Product_makefiles: = \
$ (Local_dir)/generic_vortex.mk \
$ (Local_dir)/full_vortex.mk

Device/vimicro/vortex/generic_vortex.mk
$ (Call inherit-product, device/vimicro/vortex/device_vortex.mk) // device_vortex.mk: product_copy_files batch copy!

$ (Call inherit-product, $ (src_target_dir)/product/generic. mk)
Product_name: = generic_vortex
Product_device: = vortex // value: target_device
Product_locales + = hdpi
---------------------------------------------------------------------
Then build/CORE/product_config.mk will call resolve-short-product-name to assign the product_device defined in "product. mk" matched by target_product to target_device.

3 read boardconfig:
Boardconfig. mk is related to the main board of the target platform, such as the device or driver used, or whether bootloader or kernel needs to be compiled. It is all set in boardconfig. mk. Similarly, each motherboard can have different settings, which are stored in different directories.

-> (3) read boardconfig: 129 board_config_mk: = \...... $ (Src_target_dir)/board/$ (target_device)/boardconfig. mk \
Device/*/$ (target_device)/boardconfig. mk \
The target_device here is votex, that is, to define our own product votex. target_device macro also decides target_device_dir, because target_device_dir is the path of boardconfig. mk mentioned above. That is, device/vimicro/vortex/boardconfig. mk
Target_device_dir: = $ (patsubst %/, %, $ (DIR $ (board_config_mk )))
Of course, the android ob target output is determined by target_device. For details, see build/CORE/envsetup. mk.
Product_out: = $ (target_product_out_root)/$ (target_device)
4 read all modules:
-> (4) read moudule (definitions. mk)
After the global variable configuration is completed, return to main. mk and check the compilation tool and version immediately. If the error occurs, the compilation will be interrupted.
Main. mk 160: include $ (build_system)/definitions. mk contains the file definitions. mk, which defines many variables and functions for Main. mk.
The next thing to compile the system is to traverse all subdirectories, find all android. mk files, and include these Android. mk files.
#

# Include all of the makefiles IN THE SYSTEM

#
Subdir_makefiles: = \
 
$ (Shell build/tools/findleaves. py -- prune = out -- prune =. Repo -- prune =. Git $ (subdirs) Android. mk)

Include $ (subdir_makefiles)
Let's take a look at
./Build/target/board/Android. mk
By the way, it references
Include $ (target_device_dir)/androidboard. mk
Defined by target_device_dir, The target_device directory (device/vimicro/vortex/directory) in the Device directory is entered again ), the MK file defines the need to compile and install apps and scripts for specific products.
We can see android in the root directory of each module in package/apps. MK, which defines the tag of the current local module: local_module_tags. Android uses this tag to determine which local modules will be compiled into the system, use Product and local_module_tags to determine which application packages will be compiled into the system. (As mentioned earlier, you can also use buildspec. mk to compile modules into the system)
Finally, the module path to be compiled is packaged into all_default_installed_modules:
5. Generate the image file images:
-> (5) generate the corresponding rules to survive images:
All the preparations to be configured have been completed. Next we will decide how to generate the image output file. This process is actually processed in build/CORE/makefile. Various IMG generation methods are defined here, including ramdisk. IMG, userdata. IMG, system. IMG, update.zip, and recover. IMG. When make include all files are parsed to all make files, the system will look for rules to generate corresponding targets and generate their dependencies in sequence until all satisfied modules are compiled, then use the corresponding tool to package it into the corresponding IMG.

Kernel/Android. mk
Kernel/ARCH/ARM/configs/vc0882_vortex_nand_defconfig-> kernel/. config
The main process of makefile:
The following main processes are arranged in build/CORE/Main. mk.

Initialize related parameter settings (buildspec. mk, envsetup. mk, config. mk)
Check compilation environment and target environment
Determine the target product
Read product configuration information and target platform information
Read the configuration of boardconfig
Read configurations of all modules
Generate necessary rules based on configuration (build/CORE/makefile)
Generate an image

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.