Separately compile the modules in the Android source code

Source: Internet
Author: User

Separately compile the modules in the Android source code

After downloading the Android source code for the first time, run the make command in the Android source code project to obtain the Android system image system. img.
When we modify a module in the android source code or add a module in the android source code project. At this time, you can use the make command to re-compile, but re-compile is a waste of time. Google provides additional commands to compile individual modules and repackage them into the system. img image.


The following describes how to compile the commands of modules in android and the commands for packaging system. img.

 


1. First, run the script file envsetup. sh.
In the build directory under the Android source code directory, this shell script defines functions such as hmm, croot, m, mm, and mmm.
Run the following command:


Fantasy @ ubuntu :~ /My_android $ ../build/envsetup. sh


Or

Fantasy @ ubuntu :~ /My_android $ source build/envsetup. sh


Run the hmm command in the current directory (hmm is used in android 4.2 and help is used in other versions) to display the Command provided by envsetup. sh.

Fantasy @ ubuntu :~ /My_android $ hmm
Output:


[Plain] Invoke ". build/envsetup. sh" from your shell to add the following functions to your environment:
-Lunch: lunch <product_name>-<build_variant>
-Tapas: tapas [<App1> <App2>...] [arm | x86 | mips] [eng | userdebug | user]
-Croot: Changes directory to the top of the tree.
-M: Makes from the top of the tree.
-Mm: Builds all of the modules in the current directory.
-Mmm: Builds all of the modules in the supplied directories.
-Cgrep: Greps on all local C/C ++ files.
-Jgrep: Greps on all local Java files.
-Resgrep: Greps on all local res/*. xml files.
-Godir: Go to the directory containing a file.
 
 
Look at the source to view more functions. The complete list is:
Addcompletions limit cgrep check_product limit cproj croot limit gdbclient limit gettargetarch gettop godir hmm limit jgrep key_back key_home key_menu lunch _ lunch m mangrep mm mmm pid resgrep runhat runtest set_java_home setpaths set_sequence_number set_stuff_for_environment settitle smoketest stacks startviewserver stopviewserver systemstack tapas tracedmdump

Invoke ". build/envsetup. sh" from your shell to add the following functions to your environment:
-Lunch: lunch <product_name>-<build_variant>
-Tapas: tapas [<App1> <App2>...] [arm | x86 | mips] [eng | userdebug | user]
-Croot: Changes directory to the top of the tree.
-M: Makes from the top of the tree.
-Mm: Builds all of the modules in the current directory.
-Mmm: Builds all of the modules in the supplied directories.
-Cgrep: Greps on all local C/C ++ files.
-Jgrep: Greps on all local Java files.
-Resgrep: Greps on all local res/*. xml files.
-Godir: Go to the directory containing a file.


Look at the source to view more functions. The complete list is:
Addcompletions limit cgrep check_product limit cproj croot limit gdbclient limit gettargetarch gettop godir hmm limit jgrep key_back key_home key_menu lunch _ lunch m mangrep mm mmm pid resgrep runhat runtest set_java_home setpaths set_sequence_number set_stuff_for_environment settitle smoketest stacks startviewserver stopviewserver systemstack tapas tracedmdump

 

The specific usage of these commands can be viewed by adding-help after the command. Here we only focus on the mmm command, that is, we can use it to compile all modules in the specified directory, generally, this directory contains only one module.

Note:

About source
The source command reads the content of the corresponding script to the current bash interpreter and runs it in the current execution environment; the defined functions and variables declared through export still exist in the current bash environment after the execution of source. For example, the commonly used source. bashrc or source/etc/profile is used to reference the changed environment variables.

 

 

Ii. Use mmm to compile a specified Module
The following is an experimental app that comes with android compiled by mmm. The command is as follows:

Fantasy @ ubuntu :~ /My_android $ mmm packages/experimental/CameraPreviewTest/


[Plain] ========================================== ========
PLATFORM_VERSION_CODENAME = AOSP
PLATFORM_VERSION = 4.2.2.2.2.2.2.2
TARGET_PRODUCT = full
TARGET_BUILD_VARIANT = eng
TARGET_BUILD_TYPE = release
TARGET_BUILD_APPS =
TARGET_ARCH = arm
TARGET_ARCH_VARIANT = armv7-a
TARGET_CPU_VARIANT = generic
HOST_ARCH = x86
HOST_ OS = linux
Host_ OS _extra= Linux-3.8.9-x86_64-with-Ubuntu-10.04-lucid
HOST_BUILD_TYPE = release
BUILD_ID = OPENMASTER
OUT_DIR = out
========================================================== ====
Make: Entering directory '/home/fantasy/my_android'
Target R. java/Manifest. java: VideoChatCameraTestApp (out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates/src/R. stamp)
Warning: AndroidManifest. xml already defines minSdkVersion (in http://schemas.android.com/apk/res/android); using existing value in manifest.
Warning: AndroidManifest. xml already defines targetSdkVersion (in http://schemas.android.com/apk/res/android); using existing value in manifest.
Target Java: VideoChatCameraTestApp (out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates/classes)
Note: Some input files use or override a deprecated API.
Note: Recompile with-Xlint: deprecation for details.
Copying: out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates/classes-jarjar.jar
Copying: out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates/emma_out B/classes-jarjar.jar
Copying: out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates/classes. jar
Copying: out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates proguard. classes. jar
Target Dex: VideoChatCameraTestApp
Copying: out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates proguard. classes. dex
Target Package: VideoChatCameraTestApp (out/target/product/generic/obj/APPS/VideoChatCameraTestApp_intermediates/package.apk)
Warning: AndroidManifest. xml already defines minSdkVersion (in http://schemas.android.com/apk/res/android); using existing value in manifest.
Warning: AndroidManifest. xml already defines targetSdkVersion (in http://schemas.android.com/apk/res/android); using existing value in manifest.
'Out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates/classes. dex 'as 'classes. dex '...
Processing target/product/generic/obj/APPS/VideoChatCameraTestApp_intermediates/package.apk
Done!
Install: out/target/product/generic/data/app/VideoChatCameraTestApp. odex
Install: out/target/product/generic/data/app/VideoChatCameraTestApp.apk

========================================================== ====
PLATFORM_VERSION_CODENAME = AOSP
PLATFORM_VERSION = 4.2.2.2.2.2.2.2
TARGET_PRODUCT = full
TARGET_BUILD_VARIANT = eng
TARGET_BUILD_TYPE = release
TARGET_BUILD_APPS =
TARGET_ARCH = arm
TARGET_ARCH_VARIANT = armv7-a
TARGET_CPU_VARIANT = generic
HOST_ARCH = x86
HOST_ OS = linux
Host_ OS _extra= Linux-3.8.9-x86_64-with-Ubuntu-10.04-lucid
HOST_BUILD_TYPE = release
BUILD_ID = OPENMASTER
OUT_DIR = out
========================================================== ====
Make: Entering directory '/home/fantasy/my_android'
Target R. java/Manifest. java: VideoChatCameraTestApp (out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates/src/R. stamp)
Warning: AndroidManifest. xml already defines minSdkVersion (in http://schemas.android.com/apk/res/android); using existing value in manifest.
Warning: AndroidManifest. xml already defines targetSdkVersion (in http://schemas.android.com/apk/res/android); using existing value in manifest.
Target Java: VideoChatCameraTestApp (out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates/classes)
Note: Some input files use or override a deprecated API.
Note: Recompile with-Xlint: deprecation for details.
Copying: out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates/classes-jarjar.jar
Copying: out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates/emma_out B/classes-jarjar.jar
Copying: out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates/classes. jar
Copying: out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates proguard. classes. jar
Target Dex: VideoChatCameraTestApp
Copying: out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates proguard. classes. dex
Target Package: VideoChatCameraTestApp (out/target/product/generic/obj/APPS/VideoChatCameraTestApp_intermediates/package.apk)
Warning: AndroidManifest. xml already defines minSdkVersion (in http://schemas.android.com/apk/res/android); using existing value in manifest.
Warning: AndroidManifest. xml already defines targetSdkVersion (in http://schemas.android.com/apk/res/android); using existing value in manifest.
'Out/target/common/obj/APPS/VideoChatCameraTestApp_intermediates/classes. dex 'as 'classes. dex '...
Processing target/product/generic/obj/APPS/VideoChatCameraTestApp_intermediates/package.apk
Done!
Install: out/target/product/generic/data/app/VideoChatCameraTestApp. odex
Install: out/target/product/generic/data/app/VideoChatCameraTestApp.apk
After compilation, you can view the videochatcameratestapp.apk file in the out/target/product/generic/data/app/videochatcameratestapp.apkdirectory.

 


Note:

Android apps are stored in directories ~ /My_android/out/target/product/generic/system/app.

In addition, some executable files of the Android system, such:

The executable files compiled by C are stored in the out/target/product/generic/system/bin directory,

The dynamic link library file is stored in the out/target/product/generic/system/lib directory,

The hardware abstraction layer (HAL) interface file is under the out/target/product/generic/system/lib/hw directory.

 

 

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.