Monday, October 13, 2014

Android System Building Commands

The build system uses some pre-set environment variables and a series of 'make' files in order to build an Android system and prepare it for deployment to a platform

Make targets

Here is a list of different make targets you can use to build different parts of the system:
Command
Purpose
Make sdk
Build the tools that are part of an SDK (adb, fastboot, etc.)
Make snod
Builds system image from currently available binaries
Make services
Creates the services JAR that contains all system services
Make runtime
Builds native code which serves as the glue between the Java-based Android framework and native stuff used for its functionality
Make droid
The default make
Make modules
Shows a list of all modules that can be built by using make <MODULE_NAME>
Make clean
Remove all built files (prepare for a new build). Same as rm -rf out/<configuration>
make all
make everything, whether it is included in the product definition or not

Helper macros and functions

There are some helper macros and functions that are installed when you source envsetup.sh. They are documented at the top of envesetup.sh, but here is information about a few of them:
  
Command
Purpose
croot
croot- change directory to the top of the tree
m
m - execute 'make' from the top of the tree (even if your current directory is somewhere else)
mm
mm - builds all of the modules in the current directory
mmm
mmm <dir1> ... - build all of the modules in the supplied directories
cgrep
cgrep <pattern> - grep on all local C/C++ files
jgrep
jgrep <pattern> - grep on all local Java files
resgrep
resgrep <pattern> - grep on all local res/*.xml files
godir
godir <filename> - go to the directory containing a file



Speeding up the build

You can use the '-j' option with make, to start multiple threads of make execution concurrently.
Ex: make -j4