Android compilation system

Source: Internet
Author: User

1. Android compilation steps:

  

Ii. initialize the compiling environment -- source build/envsetup. sh

Three main tasks are completed in build/envsetup. sh.

  

The code for adding the compilation target is as follows:

 f  `/bin/ vendor*/vendorsetup. devicevendorsetup. > /dev/     
3. Select the compilation target-lunch

Use lunch to select the compilation target. The function definition is as follows:

[]; = $-N =
// If no compilation target is set, the default value is full-eng, otherwise, if answer is a number, it is converted to the corresponding string to indicate [-z = full-(-n $ answer |-q-e [$ answer-=$ {LUNCH_MENU_CHOICES [$ ($ answer-(-n $ answer |-q-e =
// If the string indicating the compilation target is empty, it indicates illegal selection. If an error is returned, [-z = // check whether the selected product is valid (you only need to create vendorsetup in the corresponding directory. sh and add_lunch_combo can be used to display the corresponding items in the lunch menu, but if the product information is not configured, Invalid) =$ (-n $ selection |-e [$? -Ne = // parse the product from selection, variant local variant =$ (-n $ selection |-e [$? -Ne = [-z-o-z // export TARGET_PRODECT, TARGET_BUILD_VARIANT and TARGET_BUILD_TYPE. For example, if full-eng is selected, TARGET_PRODUCT = full, TARGET_BUILD_VARIANT = eng export TARGET_PRODUCT =
4. Compile -- make-j8

Make must have Makefile. The Makefile in the Android root directory simply includes a file:

 include build/core/ ### DO NOT EDIT THIS FILE ###  

Build/core/main. mk is complicated. The following figure shows the structure of main. mk:

In main. mk, the default compilation target is defined and the version check is performed. Then, include config. mk.

The config. mk defines the constants used to compile the target in Android. mk.

CLEAR_VARS:= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/= $(BUILD_SYSTEM)/host_native_test.mk

Then include/build/core/envsetup. sh, in envsetup. sh defines environment variables such as HOST_ OS and OUT_DIR, searches for all products through include product_config.mk, checks the validity, and sets TARGET_DEVICE according to the Product selected during lunch.

In envsetup. sh, find the BoardConfig. mk File Based on TARGET_DEVICE, configure the Board, find the KERNEL_HEADER, and configure the compilation tool chain.

The definitions. mk defines functions such as all_makefiles_under used to retrieve files.

Set system attributes such as ro. secure and tags_to_install according to TARGET_BUILD_VARIANT.

Next, use

subdir_makefiles :=/tools/findleaves.py --prune=out --prune=.repo --prune=

Find Android in all subdirectories. mk file and include it, so that in Android. the LOCAL_PACKAGE_NAME and include $ (BUILD_PACKAGE) defined by mk can be used to set the corresponding Android. the targets defined in mk are included in the compilation module. mk has the following definitions:

BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk

Package. mk includes base_rules.mk to add LOCAL_MODULE to ALL_MODULES.

Post_clean.mk is related to Resource overlay. you can define resources in framework-res.apk without modifying the original Resource file in framework.apk.

Next, include the build/core/Makefile file, define the dependency targets such as bootimage and systemimage, and compile the droid (default) target through make to compile the system.

Android retrieves Android. mk from all subdirectories to collect all modules to compile the system, rather than entering each subdirectory to execute make. This makes it easy for us to add our own modules.

 

Related Article

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.