Android source build/envsetup.sh 及lunch 过程

本文详细介绍了Android源码构建过程中,`source build/envsetup.sh`和`lunch`命令的执行过程。envsetup.sh提供了一系列自定义shell命令,包括hmm用于显示帮助。lunch用于设置编译环境,通过调用一系列函数如print_lunch_menu、check_product等确定编译选项。同时,文章探讨了系统如何查找并执行vendorsetup.sh以支持客户分支。
摘要由CSDN通过智能技术生成
1,source build/envsetup.sh
          source 是用来运行 shell 脚本的命令  功能和 "."  和相同 因此 也可以写作: . build/envsetup.sh
运行效果结果如下:
   
   
   
xxx@xxx:~/xxx/kitkat$ . build/envsetup.sh
including device/generic/armv7-a-neon/vendorsetup.sh
including device/generic/x86/vendorsetup.sh
including device/generic/mips/vendorsetup.sh
including sdk/bash_completion/adb.bash
buddy@RD3-199:~/C_BQ_T628VX_01/kitkat-mstar-master$
那么上面的结果是如何产生的呢?运行envsetup.sh的发生了什么呢?我们自己添加的客户分支是如何加入到 lunch 的选项中去的呢?
a,关于envsetup
envsetup 为我们提供了很多的shell脚本函数, 例如 envsetup 开头的第一个函数 hmm,
   
   
   
function hmm() {
cat <<EOF
Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- lunch: lunch <product_name>-<build_variant>
- tapas: tapas [<App1> <App2> ...] [arm|x86|mips|armv5] [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, but not their dependencies.
- mmm: Builds all of the modules in the supplied directories, but not their dependencies.
- 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.
- 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.
 
Look at the source to view more functions. The complete list is:
EOF
T=$(gettop)    #gettop也是envsetup.sh 中定义的一个 函数,有兴趣的童鞋可以看一下具体实现
local A
A=""
for i in `cat $T/build/envsetup.sh | sed -n "/^function /s/function \([a-z_]*\).*/\1/p" | sort`; do
A="$A $i"
done
echo $A
}
在运行 envsetup  .sh以后 就可以使用 hmm命令了,此时终端会输出命令帮助提示。
简单来说,envsetup.sh  给我们提供了一组自定义的 shell命令,而lunch 就是这些自定义命令中的一个。

2,lunch 命令
我们依然来看  envsetup.sh,在envsetup.sh 中可以找到 lunch 定义
   
   
   
function lunch()
{
local answer
 
if [ "$1" ] ; then #lunch可以接受一个输入参数,例如 lunch xxx-userdebug 此时直接选择了xxx。
answer=$1
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值