Android编译过程详解.doc

上传人:xins****2008 文档编号:111013018 上传时间:2019-11-01 格式:DOC 页数:21 大小:157KB
返回 下载 相关 举报
Android编译过程详解.doc_第1页
第1页 / 共21页
Android编译过程详解.doc_第2页
第2页 / 共21页
Android编译过程详解.doc_第3页
第3页 / 共21页
Android编译过程详解.doc_第4页
第4页 / 共21页
Android编译过程详解.doc_第5页
第5页 / 共21页
点击查看更多>>
资源描述

《Android编译过程详解.doc》由会员分享,可在线阅读,更多相关《Android编译过程详解.doc(21页珍藏版)》请在金锄头文库上搜索。

1、本文使用Android版本为2.1,采用开发板为华清远见研发的FS_S5PC100 A8开发板。+-+1. source build/envsetup.sh这个命令是用来将envsetup.sh里的所有用到的命令加载到环境变量里去,我们来分析下它。envsetup.sh里的主要命令如下:?function help() # 显示帮助信息 function get_abs_build_var()# 获取绝对变量 function get_build_var()# 获取绝对变量 function check_product()# 检查product function check_variant()

2、# 检查变量 function setpaths() # 设置文件路径 function printconfig()# 打印配置 function set_stuff_for_environment() # 设置环境变量 function set_sequence_number() # 设置序号 function settitle() # 设置标题 function choosetype() # 设置type function chooseproduct() # 设置product function choosevariant() # 设置variant function tapas() #

3、功能同choosecombo http:/ function choosecombo() # 设置编译参数 function add_lunch_combo() # 添加lunch项目 function print_lunch_menu() # 打印lunch列表 function lunch()# 配置lunch function m()# make from top function findmakefile() # 查找makefile function mm() # make from current directory function mmm() # make the suppli

4、ed directories function croot()# 回到根目录 function cproj() function pid() function systemstack() function gdbclient() function jgrep()# 查找java文件 function cgrep() # 查找c/cpp文件 function resgrep() function tracedmdump() function runhat() function getbugreports() function startviewserver() function stopview

5、server() function isviewserverstarted() function smoketest() function runtest() function godir () # 跳到指定目录 http:/ # 这是系统自动增加了一个默认的编译项 generic-eng # add the default one here add_lunch_combo generic-eng # 下面的代码很重要,它要从vendor目录下查找vendorsetup.sh文件,如果查到了,就加载它 # Execute the contents of any vendorsetup.sh f

6、iles we can find. for f in /bin/ls vendor/*/vendorsetup.sh vendor/*/build/vendorsetup.sh 2 /dev/null doecho including $f. $f done根据上面的内容,可以推测出,如果要想定义自己的产品编译项,简单的办法是直接在envsetup.sh最后,添加上add_lunch_combo myProduct-eng,当然这么做,不太符合上面代码最后的本意,我们还是老实的在vendor目录下创建自己公司名字,然后在公司目录下创建一个新的vendorsetup.sh,在里面添加上自己的产品

7、编译项?#mkdir vendor/farsight/ #touch vendor/farsight/vendorsetup.sh #echo add_lunch_combo fs100-eng vendor/farsight/vendorsetup.sh这样,当我们在执行source build/envsetup.sh命令的时候,可以在shell上看到下面的信息:?including vendor/farsight/vendorsetup.sh2. 按照android官网的步骤,开始执行lunch full-eng当然如果你按上述命令执行,它编译的还是通用的eng版本系统,不是我们个性系统,

8、我们可以执行lunch命令,它会打印出一个选择菜单,列出可用的编译选项如果你按照第一步中添加了vendorsetup.sh那么,你的选项中会出现:?Youre building on Linux generic-eng simulator fs100-eng Lunch menu. pick a combo: 1. generic-eng 2. simulator 3. fs100-eng其中第3项是我们自己添加的编译项。lunch命令是envsetup.sh里定义的一个命令,用来让用户选择编译项,来定义Product和编译过程中用到的全局变量。我们一直没有说明前面的fs100-eng是什么意

9、思,现在来说明下,fs100是我定义的产品的名字,eng是产品的编译类型,除了eng外,还有user, userdebug,分别表示:eng: 工程机,user:最终用户机userdebug:调试测试机由此可见,除了eng和user外,另外两个一般不能交给最终用户的,记得m8出来的时候,先放出了一部分eng工程机,然后出来了user机之后,可以用工程机换。好了,我们来分析下lunch命令干了什么??function lunch() local answer if $1 ; then # lunch后面直接带参数 answer=$1 else# lunch后面不带参数,则打印处所有的target

10、 product和variant菜单提供用户选择 print_lunch_menu echo -n Which would you like? generic-eng read answer fi local selection= if -z $answer then # 如果用户在菜单中没有选择,直接回车,则为系统缺省的generic-eng selection=generic-eng elif $answer = simulator then # 如果是模拟器 selection=simulator elif (echo -n $answer | grep -q -e 0-90-9*$)

11、then # 如果answer是选择菜单的数字,则获取该数字对应的字符串 if $answer -le $#LUNCH_MENU_CHOICES then selection=$LUNCH_MENU_CHOICES$($answer-$_arrayoffset) fi # 如果 answer字符串匹配 *-*模式(*的开头不能为-) elif (echo -n $answer | grep -q -e -*-*$) then selection=$answer fi if -z $selection then echo echo Invalid lunch combo: $answerretu

12、rn 1 fi # special case the simulator if $selection = simulator then # 模拟器模式 export TARGET_PRODUCT=sim export TARGET_BUILD_VARIANT=eng export TARGET_SIMULATOR=trueexport TARGET_BUILD_TYPE=debug else# 将 product-variant模式种的product分离出来 local product=$(echo -n $selection | sed -e s/-.*$/) # 检查之,调用关系 check_product()-get_build_var()-build/core/config.mk比较罗嗦,不展开了 check_product $p

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号