The first thing that comes to the android source directory is probably to execute. build/envsetup. sh first to initialize some commands. Today, we mainly analyze envsetup. sh.
1. The command-that is, the function in envsetup. sh
Function help () # display help information
Function get_abs_build_var () # obtain Absolute Variables
Function get_build_var () # obtain Absolute Variables
Function check_product () # Check product
Function check_variant () # Check Variables
Function setpaths () # Set the file path
Function printconfig () # print the configuration
Function set_stuff_for_environment () # Set Environment Variables
Function set_sequence_number () # Set the serial number
Function settitle () # Set the title
Function choosetype () # Set type
Function chooseproduct () # Set product
Function choosevariant () # Set variant
Function tapas () # functions the same as choosecombo
Function choosecombo () # Set compilation Parameters
Function add_lunch_combo () # Add a lunch project
Function print_lunch_menu () # print the lunch list
Function lunch () # configure lunch
Function m () # make from top
Function findmakefile () # Find makefile
Function mm () # make from current directory
Function mmm () # make the supplied directories
Function croot () # Return to the root directory
Function cproj ()
Function pid ()
Function systemstack ()
Function gdbclient ()
Function jgrep () # Find a java File
Function cgrep () # Find the c/cpp File
Function resgrep ()
Function tracedmdump ()
Function runhat ()
Function getbugreports ()
Function startviewserver ()
Function stopviewserver ()
Function isviewserverstarted ()
Function smoketest () function runtest ()
Function godir () # Jump to the specified directory
# Add the default one here
Add_lunch_combo generic-eng
# Execute the contents of any vendorsetup. sh files we can find.
For f in '/bin/ls vendor/*/vendorsetup. sh vendor/*/build/vendorsetup. sh 2>/dev/null'
Do
Echo "including $ f"
. $ F
Done
2. lunch command
Someone has analyzed it and moved it directly:
Http://www.lupaworld.com/home.php? Mod = space & uid = 131820 & do = blog & id = 149462
The following is a detailed explanation, many of which have not been used. It seems that I am indeed a cainiao
. Build/envsetup. sh
Build/envsetup. sh provides several useful shell commands, using
$. Build/envsetup. sh
It can be introduced into the shell environment. The following is a summary. In particular, envsetup. sh also introduces
Vendorsetup. sh script.
Help
Display help to list provided commands
Get_abs_build_var
List the values of a variable in the make script, with the current path prefix. Ref dumpvar. mk
Usage:
Get_abs_build_var VAR_NAME
VAR_NAME is the variable in the make script to be displayed.
For example:
Get_abs_build_var TARGET_PRODUCT
Returns <Your Android Root >\< VAR_NAME Value>
Get_build_var
Www.2cto.com
List the values of a variable in the make script. Ref dumpvar. mk
Usage:
Get_build_var VAR_NAME
VAR_NAME is the variable in the make script to be displayed.
Return:
<VAR_NAME Value>
Example:
Get_abs_build_var TARGET_PRODUCT
Check_product
Check whether the specified TARGET_PRODUCT is allowed. The default values are sim and generic. If not, an error message is output. If not, no echo is displayed.
Usage:
Check_product <YourTargetProduct>
Example:
Check_product generic
Check_variant
Check whether variant is supported. If supported, 0 is returned. If not, 1 is returned. The allowed variant list is defined in envsetup. sh.
In VARIANT_CHOICES, the default values are user, userdebug, and eng. You can add
Add vairant.
Usage:
Check_variant <YourVariant>
Example:
Check_variant eng
Setpaths
During odd execution, add the ANDROID_BUILD_PATHS PATH to the PATH. During the occasional execution, set the ANDROID_BUILD_PATHS path
The PATH is removed from the PATH. ANDROID_BUILD_PATHS includes the path to be used in android compilation, for example
ANDROID_EABI_TOOLCHAIN, ANDROID_TOOLCHAIN, ANDROID_QTOOLS,
ANDROID_JAVA_TOOLCHAIN, ANDROID_PRODUCT_OUT, and so on.
Usage:
Setpaths printconfig
Output configuration information similar to the following situations.
========================================================== ====
PLATFORM_VERSION_CODENAME = AOSP
PLATFORM_VERSION = AOSP
TARGET_PRODUCT = generic
TARGET_BUILD_VARIANT = eng
TARGET_SIMULATOR =
TARGET_BUILD_TYPE = release
TARGET_BUILD_APPS =
TARGET_ARCH = arm
HOST_ARCH = x86
HOST_ OS = linux
HOST_BUILD_TYPE = release
BUILD_ID = OPENMASTER
========================================================== ====
Set_stuff_for_environment
Call settitle, set_java_home, setpaths, and set_sequence_number in sequence. Set the environment variables required for android compilation.
Set_sequence_number
Output environment variable BUILD_ENV_SEQUENCE_NUMBER.
Settitle
Set the shell prompt. Add TARGET_PRODUCT, TARGET_BUILD_VARIANT, and
TARGET_BUILD_APPS and other information prompts.
Choosesim
Configure the environment variable TARGET_SIMULATOR. In linux, the user is prompted to select device or simulator. Then call
Set_stuff_for_environment settings.
Choosetype
Configure the environment variable TARGET_BUILD_TYPE_SIMULATOR. The user will be prompted to select release or debug. Then call
Set_stuff_for_environment settings. Chooseproduct
Configure the environment variable TARGET_PRODUCT. The user will be prompted to select release or debug. Call set_stuff_for_environment to set
.
Choosevariant
Configure the environment variable TARGET_BUILD_VARIANT. The user will be prompted to select release or debug.
Choosecombo
Call choosesim, choosetype, chooseproduct, choosevariant, set_stuff_for_environment, and
Call printconfig for output.
Add_lunch_combo
Add an item to the list of environment variables LUNCH_MENU_CHOICES. Full-eng, full_x86-eng, and simulator are added by default in envsetup. sh.
Print_lunch_menu
Lists all the options in LUNCH_MENU_CHOICES.
Lunch
A la carte. After the user selects/specifies the product and variant, the lunch command sets the environment variable TARGET_PRODUCT,
TARGET_BUILD_VARIANT, TARGET_SIMULATOR, TARGET_BUILD_TYPE, and then call
Set_stuff_for_environment settings and printconfig display.
Usage:
Lunch [<YourProduct>-<YourBuildVariant>]
If no parameter is specified, the user is prompted.
Example:
Lunch
Lunch generic-eng
Tapas
Given variant and one or more app names, the name is LOCAL_PACKAGE_NAME. Tapas settings
Export TARGET_PRODUCT = generic
Export TARGET_BUILD_VARIANT = $ variant
Export TARGET_SIMULATOR = false
Export TARGET_BUILD_TYPE = release
Export TARGET_BUILD_APPS = $ apps
Usage:
Tapas <YourVariant>? <YourAppName> *
? Optional. * Indicates 0, 1, or more. The order of YourVariant and YourAppName can be reversed.
Example:
Tapas user Calculator Calender
Gettop
Returns the top-level path of the current android code tree. The premise is that the current path is in the android code tree.
M
It is equivalent to executing the make command in the top-level path of the current android code tree.
Findmakefile
Search for Android. mk on the current or closest parent path and return the path of Android. mk. Assume that the current path is in the android code.
Tree.
Mm
If the current path is the top layer of the code tree, mm is equivalent to make. If it is deep, the test mm is equivalent
ONE_SHOT_MAKEFILE = $ M make-C $ T files $ @
$ M is the Android. mk found in findmakefile, $ T is the top-level path of the code tree, and files is the phony goal defined in main. mk, that is
Complete all modules to be compiled by android and the auxiliary description txt files within the $ M directory.
Mmm
Given the package path, mm will make the corresponding package.
For example,
Mmm package/apps/Calculator croot
Change the current path to the top layer of the code tree.
Cproj
Change the current path to the parent path of the latest Android. mk file.
Pid
Use the adb shell ps command to list the pid of the process with the specified name on the mobile phone.
Usage:
Pid <YourName>
Systemstack
Use kill-3system_server to write the thread information in the system process to/data/anr/traces.txt.
Gdbclient
Create a gdb debugging environment, which consists of two steps: Running gdbserver on the mobile phone and running arm-eabi-gdb on the local machine.
Usage:
Gdbclient <EXE> <PORT> <AppName>
EXE: The execution name of AppName.
PORT: gdbserver PORT, for example, 192.168.2.102: 5039
AppName: the name of the app listed by ps in the mobile phone, and the pid is queried accordingly.
Sgrep
Find all the data in the current directory and subdirectory. c ,. h ,. cpp ,. S ,. java ,. mk ,. xml ,. sh file, that is, the line containing specific words in the source code file,
And the color is displayed.
Usage:
Sgrep <YourWord>
Example:
Sgrep Calendar
Jgrep
Same as sgrep, but only the. java file is checked.
Cgrep
Same as sgrep, but only query c-related files, that is,. c,. cc,. cpp,. H files.
Resgrep
The same as sgrep, but only query the. xml file related to res.
Mgrep
The same as sgrep, but only the make-related script files, including Makefile files, all files in the Makefile directory,. make files,. mak
File and. mk file.
Treegrep
Find all. c,. h,. cpp,. S,. java, and. xml files in the current directory and subdirectory, that is, the lines containing specific words in the source code file, and display them in color.
Output.
Getprebuilt
Output prebuilt path.
Tracedmdump
Generate the dexlist file qtrace. dex, dmtrace, and dmtrace parsing files generated by calling the dmtracedump tool.
Dmtrace.html: place the generated file in the specified path.
Usage:
Tracedmdump <YourDirName>
If YourDirName does not contain '\', the path to be placed is $ ANDROID_PRODUCT_OUT/traces/YourDirName.
Runhat
It seems that the kill-10 method is used to get the heap dump and get it locally. Use hat to display it in http mode. Hat may be a lightweight http
Server.
Getbugreports
Download the files in the mobile phone/sdcard/bugreports directory to a local directory and compress and package them.
Startviewserver
Start viewserver with the specified port.
Usage:
Startviewserver <Port>
If no port is specified, 4939 is used by default.
Stopviewserver
Disable viewserver.
Isviewserverstarted
Check whether viewserver is available.
Smoketest
Compile smoketest and install it on your mobile phone.
Runtest
Run development/testrunner/runtest. py $ @
Godir
A word is provided, and godir will output a path list for the user to choose the path to enter. The path in the path list is satisfied. The path name contains the word, or the file in the path contains the name of the file. Out/path is not considered.
Usage:
Godir <YourKey>
Usage:
Godir Calculator
Set_java_home
Set the JAVA_HOME environment variable to/usr/lib/jvm/java-6-sun.
Author: LuoXianXion