After the first download of the Android source code project, we usually execute make command under the Android source code engineering directory, after a long wait, we can get the android system Mirror system.img. If we modify a module in the Android source code or add a new module to the Android source code, do we still execute make? The answer is no, Google has prepared additional commands for us to support the compilation of separate modules and to repackage SYSTEM.IMG commands. Before continuing to learn the Android source code, let's take a look at this command first.
first, in the Android source directory under the build directory, there is a script file envsetup.sh, execute this script file, you can get some useful tools:
user-name@machine-name:~/android$ . ./build/envsetup.sh
Note: This is a source command, and after execution, there will be additional commands to use:
-Croot:changes directory to the "top" tree.
-M:makes from the "top" of the tree.
-Mm:builds all of the "modules in" current directory.
-Mmm:builds the modules in the supplied directories.
-Cgrep:greps on "All" local/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.
The specific usage of these commands can be viewed in the-help of the command, where we focus only on the MMM command, which is that it can be used to compile all the modules of the specified directory, which typically contain only one module.
two. Use the MMM command to compile the specified module, such as an email application:
user-name@machine-name:~/android$ mmm packages/apps/email/
After the compilation is complete, you can see the email.apk file in the Out/target/product/generic/system/app directory. Android's own apps are all in this directory. In addition, some of the Android executable files, such as C-compiled executables, are placed in the Out/target/product/generic/system/bin directory, and dynamic link library files are placed in the out/target/product/ Generic/system/lib directory, the OUT/TARGET/PRODUCT/GENERIC/SYSTEM/LIB/HW directory is stored in the Hardware Abstraction Layer (HAL) interface file, the following article, we will be mentioned, please pay attention to.
three. After compiling the module, we should repackage the system.img file so that we can see our program when we run the system.img on the simulator.
user-name@machine-name:~/android$ make Snod
four. Run the simulator in the context of downloading, compiling, and installing the latest Android source code for Ubuntu:
user-name@machine-name:~/android$ Emulator
So it's all done.
Want to study the android source of small partners to help!