腦袋一熱,決定down下來android source code,下了一晚上,我了個去,30多個G(是不是下錯了。。)
一、前期準備:
1、mac下我們需要創建一個大小寫敏感的磁盤鏡像文件,並將其掛載,進入應用程序/實用工具/磁盤工具,選擇文件->新建->新建空白映像:
空間大小自定義,建議50G,格式Mac os拓展(區分大小寫),映像格式選擇稀疏磁盤映像。
2、從macports.org安裝MacPorts
macports基本命令:
(1)sudo port install ?安裝
(2)sudo port uninstall ?卸載
(3) port installed 查看已安裝的軟件
這三個就夠用了這裏
3、執行sudo port install gmake libsdl git-core gnupg命令安裝gmake,libsdl,git,gnupg。我這裏直接安裝了gmake4.1。
如果以前安裝了Xcode,安裝git-core的過程中出現問題,直接重裝git。(如果which
git
返回的結果是/usr/bin/git
,說明你可能通過XCode安裝了其自帶的GIT,自帶的git版本低了點)
4、安裝完成之後port installed看一下時候上面提到的都安裝了,接着如下:
修改文件標識符限制:
由於MacOS默認將同時打開的文件標識符數量限制得太小,並行編譯處理時可能會超出這個限制。所以在 ~/.profile里加
上這麼一段:
#set the number of open files to be 1024
ulimit -S -n 1024
二、下載源碼:
1.創建~/bin/目錄
$mkdir ~/bin
$PATH=~/bin:$PATH
2.安裝repo
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
curl http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo > ~/bin/repo
這兩個命令隨便選一個,哪個好用用哪個。可以多試兩遍。
3.設置repo可執行權限
$chmod a+x ~/bin/repo
4.接下來執行repo init
repo init -u git://codeaurora.org/platform/manifest.git -b gingerbread (備註因爲買的數是基於gingerbread源
碼的,應該也是可以更改其他android分支,具體可參考:https://android.googlesource.com/platform/manifest)
執行完成後ls -a查看是否一個.repo文件夾,進入看到有manifest.xml文件,如果有那麼我們接下來就可以下載源碼了。
如果出現repo: command not found。方法如下:
export PATH=$PATH:$HOME/bin
5.下載源碼
在/Volumes/android目錄下執行命令:repo sync
參考:http://blog.csdn.net/ym19860303/article/details/7735010
http://blog.csdn.net/android_panda/article/details/17488523
http://blog.csdn.net/joshua_yu/article/details/6876978
http://www.cnblogs.com/liuqxFuture/archive/2012/12/18/2823717.html
http://afrv.blog.163.com/blog/static/56342141201041710412189/