ROM Android: Tentang Envsetup
This page explains what happens when you run the the "$ . build/envsetup.sh
" or "$ source build/envsetup.sh
" script from the ~android/system/
directory.
At a glance
Invoking "$ source build/envsetup.sh
" or "$ . build/envsetup.sh
" from your shell runs the envsetup.sh
script in the build
directory. envsetup.sh
adds many functions to the build environment, the most important of which are listed below. For a full list of functions see All commands.
mka |
Builds using SCHED_BATCH on all processors |
lunch |
lunch <vendor_name>_<product_name>-<build_variant> |
breakfast |
breakfast <product_name> |
brunch |
brunch <product_name> |
omnom |
omnom <product_name> |
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 |
mmp |
Builds all of the modules in the current directory and pushes them to the device |
mmm |
Builds all of the modules in the supplied directories |
mmmp |
Builds all of the modules in the supplied directories and pushes them to the device |
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 |
cmremote |
Add git remote for CM Gerrit Review |
cmgerrit |
A Git wrapper that fetches/pushes patch from/to CM Gerrit Review |
cmrebase |
Rebase a Gerrit change and push it again |
aospremote |
Add git remote for matching AOSP repository |
mkap |
Builds the module(s) using mka and pushes them to the device |
cmka |
Cleans and builds using mka |
reposync |
Parallel repo sync using ionice and SCHED_BATCH |
installboot |
Installs a boot.img to the connected device |
installrecovery |
Installs a recovery.img to the connected device |
We will look at a few important functions that "$ . build/envsetup.sh
" adds to the build environment in detail below.
mka
This little gem of a command is basically equivalent to a super-charged version of make
. make
is the program that gets called to build our source, choosing the correct compiler for each part of the Android OS that we are making. Problem is, make is SLOW in its default configuration. It can take hours longer depending on your hardware. So what did they do? They mated make
with a cheetah, and took their child mka
. mka
improves upon make
by using the program sched_tool
to make full use of all the threads available on your machine (For AMD, this is equivalent to the number of cores your processor has; For Intel, this is usually equivalent to twice the number of cores your processor has, due to HyperThreading). What this means is that ALL of your processor is working, not just one small part of it.
breakfast
You may not ever use this command, but in order to explain brunch, we have to explain breakfast first. Breakfast is a function used to configure your build. It keeps track of a list of officially-supported devices to build for, and allows you to choose one. You can do this two ways,
$ breakfast [device name]
or
$ breakfast (no device name)
The first method is like a shortcut to select your device. If you do not put a device, the script will output a list of available devices to build for (limited to those CM builds nightlies for, which isn't necessarily complete), and you can then choose yours. breakfast
then goes on to configure your build environment with the correct variables to create your device-specific rom.
brunch
Defined simply, brunch
is equivalent to
$ breakfast [device name] && mka bacon
This means that it sets up your build environment to be configured for your device, and then commences the build process. mka bacon
is just CyanogenMods’s way of saying build the code for your device. It’s generally only used for officially supported devices (those for which a public CyanogenMod-maintained device repository exists).
lunch
This one's also pretty simple to explain. It’s used EXACTLY like breakfast
, the only difference being the choices you have to build with it, and how it configures the device. Using lunch, you can choose non-official or non-standard builds for your device. This includes special debug versions and also allows you to build CyanogenMod for use on the Android Emulator. Unlike breakfast
, lunch
makes no assumptions with regard to device configuration locations and formats, so it will scan the entire tree for matching options (depending on the number of locally available devices, this may take a significant amount of time). To build after running lunch
, simply issue the command mka
. No bacon here… sorry.
List of all commands in envsetup.sh
- addcompletions
- add_lunch_combo
- aospremote
- breakfast
- brunch
- cgrep
- check_product
- check_variant
- choosecombo
- chooseproduct
- choosetype
- choosevariant
- cmgerrit
- cmka
- cmrebase
- cmremote
- cproj
- croot
- dopush
- eat
- findmakefile
- gdbclient
- get_abs_build_var
- getbugreports
- get_build_var
- getlastscreenshot
- getprebuilt
- getscreenshotpath
- getsdcardpath
- gettargetarch
- gettop
- godir
- hmm
- installboot
- installrecovery
- isviewserverstarted
- jgrep
- key_back
- key_home
- key_menu
- lunch
- _lunch
- m
- makerecipe
- mka
- mm
- mmm
- omnom
- pid
- printconfig
- print_lunch_menu
- repodiff
- reposync
- resgrep
- runhat
- runtest
- set_java_home
- setpaths
- set_sequence_number
- set_stuff_for_environment
- settitle
- smoketest
- startviewserver
- stopviewserver
- systemstack
- tapas
- tracedmdump