Mac 10.11 android6.0源码编译

来源:互联网 发布:fms飞机淘宝 编辑:程序博客网 时间:2024/06/10 21:41
关于android源码编译,以前在ubantu下编译4.x 版本出了好多问题,最近换了mac,编译下android6.0版本,编译过程基本没有什么问题一.编译环境配置   参照:http://source.android.com/source/initializing.html   mac下主要做了两件事情   1.创建大小写敏感硬盘,mac的文件系统是大小写不敏感的,不适合android    源码编译,我分配了80G硬盘,编译6.0源码和内核基本够用。编译6.0建议至少60g,6.0源码下载大概28G左右,编译过程会产生很多编译文件。创建大小写文件系统如下
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">    hdiutil create <span class="hljs-attribute" style="box-sizing: border-box;">-type</span> SPARSE <span class="hljs-attribute" style="box-sizing: border-box;">-fs</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'Case-sensitive Journaled HFS+'</span> <span class="hljs-attribute" style="box-sizing: border-box;">-size</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">80</span>g ~/android<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>dmg</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

运行以上命令会创建一个80G大小写敏感文件系统。 
为了方便以后挂载该文件系统,可以创建一个function amountAndroid ,命令如下

<code class="hljs javascript has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">function</span> <span class="hljs-title" style="box-sizing: border-box;">mountAndroid</span> {</span> hdiutil attach ~<span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/android.dmg.sparsefile.sparseimage -mountpoint /</span>Volumes/android; }</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

以后只要运行 mountAndroid就可以挂载该文件系统了。 
2.jdk安装 
编译不同版本的Android源码对jdk的版本要求不一样,对于mac中多个jdk版本可以通过jenv来进行管理,具体google,android6.0的编译需要jdk为1.7。 
二.源码下载 
1.工具 
repo 
anroid源码包含多个git仓库,repo用来管理以及下载这些git仓库以及控制她们的之间的依赖关系。repo下载和安装如下:

<code class="hljs smalltalk has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span class="hljs-char" style="box-sizing: border-box;">$ </span>mkdir ~/bin  创建一个bin目录<span class="hljs-char" style="box-sizing: border-box;">$ </span><span class="hljs-class" style="box-sizing: border-box; color: rgb(102, 0, 102);">PATH</span>=~/<span class="hljs-method" style="box-sizing: border-box;">bin:</span><span class="hljs-char" style="box-sizing: border-box;">$P</span>ATH 将bin加入path<span class="hljs-char" style="box-sizing: border-box;">$ </span>curl <span class="hljs-method" style="box-sizing: border-box;">https:</span>//storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo 下载repo<span class="hljs-char" style="box-sizing: border-box;">$ </span>chmod a+x ~/bin/repo 添加可执行权限</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul>
    2.使用国内镜像下载     清华镜像:https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/     中科大镜像:https://lug.ustc.edu.cn/wiki/mirrors/help/aosp     实测中科大镜像稳定且下载速度快。
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>repo init -u <span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">git:</span>/<span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/mirrors.ustc.edu.cn/aosp</span><span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/platform/manifest</span> -b android-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6.0</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0_</span>r26  下载mainfest mainfest记录<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>repo sync 下载源码</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>
三.编译初始化环境
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>source build/envsetup.sh  初始化环境<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>lunch aosp_arm-eng 选择编译版本</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>
编译
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">    make <span class="hljs-attribute" style="box-sizing: border-box;">-j16</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

macbook pro 编译了不到2个小时,中间没有编译错误。

0 0