Android Build System详解<一>

本文深入探讨了Android Build系统的核心架构及其初始化过程,包括顶层目录结构、Makefile文件、envsetup.sh脚本的功能及使用方法。详细介绍了如何通过envsetup.sh脚本进行编译环境的设置,以及如何利用add_lunch_combo函数配置组合选项,从而实现整个Android系统的编译。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Android Build System Architecture

其中$(TOP)/Makefile位于android的顶层目录中。其它Makefile文件均位于$(TOP)/build/core目录下

Initialize the environment

   初始化编译环境使用的是$(TOP)/build/envsetup.sh脚本。
envsetup.sh提供的函数如下:
函数功能
hmm帮助命令,envsetup.sh提供的函数的用法
get_abs_build_var
get_build_var
check_product
check_variant
setpaths
printconfig
set_stuff_for_environment
set_sequence_number
settitle
addcompletions
choosetype
chooseproduct
choosevariant
choosecombo
add_lunch_combo
print_lunch_menu
lunch
_lunch
tapas
gettop
getdriver
m从顶层目录build整个系统
mmmbuild指定目录下所有的模块
mmabuild当前目录下所有的模块以及这些模块所依赖的模块
mmmabuild指定目录下所有的模块以及这些模块所依赖的模块
croot到android所在的顶层目录
cproj
qpid
pid
systemstack
stacks
gdbwrapper
sgrep
gettargetarch
jgrep
cgrep
resgrep
mangrep
sepgrep
mgrep
treegrep
getprebuilt
tracedmdump
runhat
getbugreports
getsdcardpath
getscreenshotpath
startviewserver
isviewserverstarted
key_home
key_back
key_menu
smoketest
runtest
godir
set_java_home
pez
findnmakefile
gdbcleint

# Clear this variable.  It will be built up again when the vendorsetup.sh
# files are included at the end of this file.
unset LUNCH_MENU_CHOICES
function add_lunch_combo()
{
    local new_combo=$1
    local c
    for c in ${LUNCH_MENU_CHOICES[@]} ; do 
        if [ "$new_combo" = "$c" ] ; then 
            return
        fi   
    done 
    LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo)
}

# add the default one here
add_lunch_combo aosp_arm-eng
add_lunch_combo aosp_x86-eng
add_lunch_combo aosp_mips-eng
add_lunch_combo aosp_x86_64-eng
add_lunch_combo vbox_x86-eng
调用add_lunch_combo函数将 combo配置到LUNCH_MENU_CHOICES变量中。lunch命令就是选择combo。
# Execute the contents of any vendorsetup.sh files we can find.
for f in `test -d device && find device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null` \
         `test -d vendor && find vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null`
do
    echo "including $f"
    . $f
done
unset f
搜索device目录下所有的vendorsetup.sh,并执行。下面是ti的vendorsetup.sh的例子:
add_lunch_combo  full_panda-userdebug
其中full_panda-userdebug分为两部分,一部分是product name:full_panda,一部分是Build variant:userdebug. build variant共有三种选择分别是user, userdebug, eng

eng:工程机
user:最终用户机
userdebug:调试测试机
编译环境设置完成后,就可以编译整个android系统。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值