android系统开发每次编译系统使用为什么都要先执行envsetup.sh文件

android系统开发每次编译系统都要先执行envsetup.sh文件,这是为什么,

  • 今天我们从build/envsetup.sh文件的开头位置找到了原因
  • 原因就是执行. build/envsetup.sh这个脚本就会临时添加下面的shell函数到我们的环境变量,后续使用的lunch、make、m、mm等命令才有效
  • 除了常用的lunch、make、m命令之外,其他的命令也可以从这里找到并熟悉它们,不用每次都到处百度搜索了
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.
- 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.
  • 执行m help可以查看编译步骤
1. source ./build/envsetup.sh
2. m help
posted @ 2024-07-11 11:41  yongfengnice  阅读(4)  评论(0编辑  收藏  举报