Refer to https://elinux.org/Android_Build_System
Refer to https://android.googlesource.com/platform/build/+/master/core/Makefile
Make targets
Here is a list of different make targets you can use to build different parts of the system:
make sdk
- build the tools that are part of an SDK (adb, fastboot, etc.)make snod
- build the system image from the current software binariesmake services
make runtime
make droid
- make droid is the normal build.make all
- make everything, whether it is included in the product definition or notmake clean
- remove all built files (prepare for a new build). Same as rm -rf out/<configuration>/make modules
- shows a list of submodules that can be built (List of all LOCAL_MODULE definitions)make <local_module>
- make a specific module (note that this is not the same as directory name. It is the LOCAL_MODULE definition in the Android.mk file)make clean-<local_module>
- clean a specific modulemake bootimage TARGET_PREBUILT_KERNEL=/path/to/bzImage
- create a new boot image with custom bzImage
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:
hmm
- List this help textlunch <product_name>-<build_variant>
- Load product & build variant config (driver files, device specific configs, etc).tapas [<App1> <App2> ...] [arm|x86|mips|armv5|arm64|x86_64|mips64] [eng|userdebug|user]
- command is for building unbundled apps. If you don't supply a build variant, it defaults to eng.provision
- Flash device with all required partitions. Options will be passed on to fastboot.
Build Macros and functions
croot
- change directory to the top of the treem
- execute 'make' from the top of the tree (even if your current directory is somewhere else)mm
- builds all of the modules in the current directorymmm <dir1> ...
- Builds all of the modules in the supplied directories, but not their dependencies. To limit the modules being built use the syntax: mmm dir/:target1,target2.mma
- Builds all of the modules in the current directory, and their dependencies.mmma <dir1> ...
- Builds all of the modules in the supplied directories, and their dependencies.
Grep macros and functions
cgrep <PATTERN>
Greps on all local C/C++ files.ggrep <PATTERN>
Greps on all local Gradle files.jgrep <PATTERN>
Greps on all local Java files.resgrep <PATTERN>
Greps on all local res/*.xml files.mangrep <PATTERN>
Greps on all local AndroidManifest.xml files.mgrep <PATTERN>
Greps on all local Makefiles files.sepgrep <PATTERN>
Greps on all local sepolicy files.sgrep <PATTERN>
Greps on all local source files.godir <filename>
Go to the directory containing a file