"Turn" Android Building System Summary-One drunken thousand years-csdn blog

Source: Internet
Author: User

Original URL: http://www.360doc.com/content/15/0314/23/1709014_455175716.shtml

Android Building System Summary Collection
Took one months to see Android make, on the internet always see such a prawn said one day to the Android made overview a bit, have to sigh now the strong shrimp and we even snails can despise the progress. But always a complete look at the Android make this system, had to structure the mechanism of the God-man worship, pious to burn three pillars Sakuradani, marvel at the great time of the Man of God also the more sense of his bucket, struck, back without shore, refueling water ski.
Gossip is not much to say, to see this mechanism, Android in the form of modules to organize the components of various systems, ENG professional point of the vocabulary is module, is that you can be seen in almost every directory android.mk. You can easily divide all the make files of Android into 4 types:
1. For config
This type of file is primarily configured for Product,board, as well as selecting the appropriate tool based on your host and target and setting the appropriate generic compilation options:
Build/core/config.mk Summary of Config
Build/core/envsetup.mk generate dir config and so on
Build/target/product Product Config
Build/target/board Board Config
Build/core/combo Build Flags Config
This explains the board and product here. Borad is mainly designed to the hardware chip configuration, such as whether to provide some features of the hardware, such as GPU, or chip support floating point operation and so on. Product is defined as the configuration of the product you are going to produce for the current chip configuration, primarily the apk aspect, which APK will be included in which product, and which APK is not available in the current product.
Config.mk is an overarching thing that defines the host tools to be used by the various module compilers and how to compile various modules, such as Built_prebuilt, which defines how to compile precompiled modules. Envsetup.mk mainly reads the variables that are written to the environment variable by envsetup.sh to configure the output directory during compilation, combo the main definition of various host and target compiler and compiler options.
2. Module Compile
This type of file mainly defines how to deal with module Android.mk, and how to generate the target module, these module generation rules are defined in the CONFIG.MK, we can look at:
Clear_vars:= $ (Build_system)/clear_vars.mk
Build_host_static_library:= $ (Build_system)/host_static_library.mk
Build_host_shared_library:= $ (Build_system)/host_shared_library.mk
Build_static_library:= $ (Build_system)/static_library.mk
Build_raw_static_library: = $ (Build_system)/raw_static_library.mk
Build_shared_library:= $ (Build_system)/shared_library.mk
Build_executable:= $ (Build_system)/executable.mk
Build_raw_executable:= $ (Build_system)/raw_executable.mk
Build_host_executable:= $ (Build_system)/host_executable.mk
Build_package:= $ (Build_system)/package.mk
Build_host_prebuilt:= $ (Build_system)/host_prebuilt.mk
Build_prebuilt:= $ (Build_system)/prebuilt.mk
Build_multi_prebuilt:= $ (Build_system)/multi_prebuilt.mk
Build_java_library:= $ (Build_system)/java_library.mk
Build_static_java_library:= $ (Build_system)/static_java_library.mk
Build_host_java_library:= $ (Build_system)/host_java_library.mk
Build_droiddoc:= $ (Build_system)/droiddoc.mk
Build_copy_headers: = $ (Build_system)/copy_headers.mk
Build_key_char_map: = $ (Build_system)/key_char_map.mk
Except that Clear_vars is clear about local variables, everything else corresponds to a module's generation rules, and each local module will include one of them to generate the target module. Most of the above. Mk will contain base_rules.mk, which is the basic file to process the module, it is recommended to write the local module to see, see why Android.mk to write this will be roughly understood.
3. Local Module
The makefile file for the local module is the android.mk that we have on Android almost everywhere. When Android compiles, it iterates through the android.mk in all subdirectories using the following function, and once found, it will not continue looking for the layer subdirectory (all of your module-defined top-level android.mk must contain ANDROID.MK in its own defined subdirectory).
Subdir_makefiles + = \
$ (Shell build/tools/findleaves.sh--prune= "./out" $ (subdirs) android.mk)
Different types of local modules have different syntax, but basically the same, only the individual variables, how to add modules in the previous post has been said, we can refer to.
Android uses Local_module_tags to determine which local modules will not be compiled into the system, through product and local_module_tags to determine which application packages are compiled into the system if the user does not specify Local_module_tags , the default value for this is user. In addition, users can specify which modules you need to compile into the system via BUILDSPEC.MK.
The user can also compile the specified module via mm, or delete the specified module via make clean-module_name.
4. Package
This refers primarily to the Build/core/makefile file, which defines the way in which various img are generated, including ramdisk.img userdata.img system.img Update.zip recover.img, and so on. We can look at how these img are generated, corresponding to our common make goals: in the actual process, we can also edit the generated files in the out directory, and then manually package corresponding to generate the corresponding IMG, the most common is to add some need to integrate into the prebuilt File

All makefile are organized by build/core/main.mk this file, which defines a default goals:droid, and when we tap make in the top directory, it is actually equivalent to executing the make droid.       When make include all the files, complete the parsing of all made my files and then look for the rules that generate the droid, generate its dependencies sequentially until all the satisfied modules are compiled, and then package the corresponding IMG with the appropriate tools. Basically Android building system is organized in such a way together, the following is a little idle things. The first is how to speed up the Android compilation process, because every time Android is going to traverse all the android.mk, whether it's compiling the entire project or just compiling a module. So you can save the results of the traversal, the next time directly from the file to read, but it is easy to make mistakes, so be sure to confirm whether the correct inclusion of all. MK, when newly added to the file, confirm that the original saved files are deleted. Here's what I wrote to speed up the compilation of a makefile, the following statement to replace the corresponding part of the MAIN.MK:
From:
Subdir_makefiles + = \
$ (Shell build/tools/findleaves.sh--prune= "./out" $ (subdirs) android.mk)
To:
Ifneq ($ (one_shot_makefile),)
Else
Ifneq ($ (CASH_MK), true)
Subdir_makefiles + = \
$ (Shell build/tools/findleaves.sh--prune= "./out" $ (subdirs) android.mk)
Else
Subdir-makefiles-cash: = $ (Shell cat Build/subdir_mk_cash)
Ifeq ($ (subdir-makefiles-cash),)
$ (Warning No. MK Cash, create now!)
Subdir_makefiles + = \
$ (Shell build/tools/findleaves.sh--prune= "./out" $ (subdirs) android.mk)
Mk-to-file: = $ (Shell echo $ (subdir_makefiles) > Build/subdir_mk_cash)
Else
$ (Warning Using Cash MK!)
Subdir_makefiles: = $ (Shell cat Build/subdir_mk_cash)
endif
endif
endif
Use Cash_mk=true to turn on the quick compile feature because there is no action to detect errors, so be careful when using them. The last one is the extension of the SDK API, Android can compile its own SDK, and expand the corresponding SDK API, and now no careful study, only to understand that a rude method is to add the appropriate class in the Frameworks/base/core/java. If you have time in the future, study it carefully.
This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/yili_xie/archive/2009/12/14/5004205.aspx

"Turn" Android Building System Summary-One drunken thousand years-csdn blog

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.