Original URL: http://blog.csdn.net/androidlover1991/article/details/17014055
In actual development, it is not necessary to compile all the source code each time, only need to compile their own modified modules.
Android's compilation system provides a powerful mechanism to support the compilation of individual modules, and is very simple. Android offers three
Methods for compiling individual modules:
1.make Module Name
2.MM functions registered in the envsetup.sh script
3. Mmm comes from a function registered in the envsetup.sh script
These three methods are described separately below.
1.make Module Name
This method is suitable for the first compilation and will compile the dependent modules together. It needs to find the compiler in all the source code
Block of android.mk files, and check if the dependent modules are modified, so the compilation time is longer. Using this method, I
We only need to search the source directory of the Android.mk file, find the module name, and then assign to make.
(1) Compile the application layer source code
For application-level programs, you need to view the Local_package_name variable for the android.mk file.
For example, to compile the phone application's source code, first look at the phone's android.mk file, run in the terminal
The following command:
[Email protected]:~/android/jellybean$ cat Packages/apps/phone/android.mk
The contents of the display android.mk are as follows:
...... (Omit some content)
Local_path:= $ (call My-dir)
Include $ (clear_vars)
Local_module: = Com.android.phone.common
...... (Omit some content)
Local_package_name: = Phone
...... (Omit some content)
Find the Local_package_name field, whose value is the compilation parameter we need to get, i.e. the Phone.
Once the compilation parameters are obtained, the Phone module and its dependent modules can be compiled separately by running the following command in the terminal:
[Email Protected]:~/android/jellybean$make Phone
(2) Compile the framework layer and the system run-time library source code
For the framework layer and the system runtime, you need to look at the Local_module variable.
Take the source code in the frameworks package as an example and run the following command in the terminal:
[Email protected]:~/android/jellybean$ find
Frameworks-name android.mk
This command will search all the android.mk files in the frameworks directory, as shown in the following list:
Frameworks/media/libvideoeditor/lvpp/android.mk
Frameworks/media/libvideoeditor/osal/src/android.mk
Frameworks/base/cmds/app_process/android.mk
...... (Omit other parts)
In App_process, for example, run the following command in the terminal:
[Email protected]:~/android/jellybean$ Cat
Frameworks/base/cmds/app_process/android.mk
The contents of the display android.mk are as follows:
Local_path:= $ (call My-dir)
Include $ (clear_vars)
local_module:= app_process
Include $ (build_executable)
The value of the Local_module variable is the module name we are looking for. Run the following command in the terminal:
[Email Protected]:~/android/jellybean$make app_process
2.mmm command
This command is a function registered in envsetup.sh to compile the specified module at the root of the source code, the parameter is relative to the module
Path. Can only be used after the first compilation. For example, to compile the Phone part of the source code, you need to execute the following command in Terminal:
[Email protected]:~/android/jellybean$mmm packages/apps/phone
3.MM command
This command is also a function registered in envsetup.sh to compile the module at the root of the module. Only for the first time
Used after compilation. For example, to compile the Phone part of the source code, you need to execute the following command in Terminal:
[Email PROTECTED]:~/ANDROID/JELLYBEAN$CD packages/apps/phone
[Email protected]:~/android/jellybean/packages/apps/phone$mm
Note that the MMM and MM commands must not be used until the ". Build/envsetup.sh" is executed and only the changed text is compiled
Thing If you want to compile all the files for a module, you need the-B option, such as Mm-b.
"Go" module compiled Android source code method