今天看到身边的同事在使用croot命令,可以直接跳转到Android根目录,遂产生了好奇,这可是我实际开发中的一个痛点啊,还是孤陋寡闻了。赶紧的,研究研究~
在Android源码根目录执行完 source build/envsetup.sh
命令后,在当前目录在执行hmm
命令可查看到该source命令新增的一系列命令工具,这些工具可以大大提高我们在Android代码上的开发效率,还发现Android高版本比低版本新增了些命令,看来Android也一直为工程师的开发效率操心那,强烈推荐~
calm.xia@shand09[17:53:11]:~/10_automotive$ hmm
Run "m help" for help with the build system itself.
Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- lunch: lunch <product_name>-<build_variant>
Selects <product_name> as the product to build, and <build_variant> as the variant to
build, and stores those selections in the environment to be read by subsequent
invocations of 'm' etc.
- tapas: tapas [<App1> <App2> ...] [arm|x86|mips|arm64|x86_64|mips64] [eng|userdebug|user]
- croot: Changes directory to the top of the tree, or a subdirectory thereof.
- m: Makes from the top of the tree.
- mm: Builds all of the modules in the current directory, but not their dependencies.
- mmm: 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: Builds all of the modules in the supplied directories, and their dependencies.
- umake: Call ninja directly to speed up build when there is no modifications to .mk or .bp files.
- provision: Flash device with all required partitions. Options will be passed on to fastboot.
- cgrep: Greps on all local C/C++ files.
- ggrep: Greps on all local Gradle files.
- jgrep: Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
- mangrep: Greps on all local AndroidManifest.xml files.
- mgrep: Greps on all local Makefiles files.
- sepgrep: Greps on all local sepolicy files.
- sgrep: Greps on all local source files.
- godir: Go to the directory containing a file.
- allmod: List all modules.
- gomod: Go to the directory containing a module.
- pathmod: Get the directory containing a module.
- refreshmod: Refresh list of modules for allmod/gomod.
Environment options:
- SANITIZE_HOST: Set to 'true' to use ASAN for all host modules. Note that
ASAN_OPTIONS=detect_leaks=0 will be set by default until the
build is leak-check clean.
- ANDROID_QUIET_BUILD: set to 'true' to display only the essential messages.
Look at the source to view more functions. The complete list is:
addcompletions add_lunch_combo allmod build_analysis build_build_var_cache build_tool_and_sign_images cgrep check_product check_type check_variant check_version choosecombo chooseproduct choosetype choosevariant chooseversion _complete_android_module_names core coredump_enable coredump_setup cproj cp_sign croot _croot destroy_build_var_cache enable_zsh_completion findmakefile get_abs_build_var get_all_build_vars getbugreports get_build_var getlastscreenshot get_make_command getprebuilt getscreenshotpath getsdcardpath gettargetarch gettop ggrep godir gomod hmm is isviewserverstarted jgrep key_back key_home key_menu lunch _lunch m make makeota makepac mangrep mgrep mm mma mmm mmma pathmod pez printconfig print_lunch_menu provision qpid rcgrep refreshmod resgrep runhat runtest sepgrep setpaths set_sequence_number set_stuff_for_environment sgrep should_add_completion smoketest source_vendorsetup startviewserver stopviewserver systemstack tapas tracedmdump treegrep umake validate_current_shell _wrap_build