一爬坑、設置 Mac 編譯環(huán)境
- 參考Setting up a Mac OS build environment
- 建一個大小寫敏感的分區(qū)
# hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 80g ~/android.dmg
# 想更改該分區(qū)大小時
# hdiutil resize -size <new-size-you-want>g ~/android.dmg.sparseimage
- 掛載分區(qū)
在 ~/.bash_profile(如果是 zsh战授,則為 .zshrc) 中添加下列代碼娇未。
# mount the android file image
function mountAndroid { hdiutil attach ~/android.dmg.sparseimage -mountpoint /Volumes/android; }
# unmount the android file image
function umountAndroid() { hdiutil detach /Volumes/android; }
調用 mount 來掛載分區(qū)淫僻,unmount 來卸載妇拯。
- 其他
在 ~/.bash_profile ( 或者 .zshrc )中添加:
export PATH=/opt/local/bin:$PATH
# set the number of open files to be 1024
ulimit -S -n 1024
二蛛芥、下載
從清華大學下載源碼:清華大學 TUNA 鏡像源 商膊。
- 下載 repo 工具:
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
- 使用每月更新的初始化包
由于首次同步需要下載 24GB 數(shù)據(jù)饶囚,過程中任何網(wǎng)絡故障都可能造成同步失敗帕翻,我們強烈建議您使用初始化包進行初始化。
下載 https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar萝风,下載完成后記得根據(jù) checksum.txt 的內容校驗一下嘀掸。
wget https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar
# 下載初始化包
tar xf aosp-latest.tar
cd AOSP
# 解壓得到的 AOSP 工程目錄# 這時 ls 的話什么也看不到,因為只有一個隱藏的 .repo 目錄
- 指定特定的 Android 版本(列表)闹丐,并同步
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-6.0.1_r41
repo sync
- 下載對應的驅動
Binaries for Nexus Devices
從版本列表中可以看到對應的驅動編號横殴。
從這里下載對應的驅動文件到源碼目錄,下載完成后解壓卿拴,會發(fā)現(xiàn)三個sh文件衫仑,依次執(zhí)行,例如:
$ ./extract-broadcom-hammerhead.sh
The license for this software will now be displayed.
You must agree to this license before using this software.
Press Enter to view the licenses
回車后查看license堕花,翻到license最后文狱,輸入I ACCEPT后回車,這時會將驅動文件釋放到vendor目錄缘挽。
三瞄崇、編譯
- 配置編譯環(huán)境
source build/envsetup.sh
- 選擇對應的設備
You're building on Darwin
Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_mips-eng
4. aosp_mips64-eng
5. aosp_x86-eng
6. aosp_x86_64-eng
7. aosp_deb-userdebug
8. aosp_flo-userdebug
9. full_fugu-userdebug
10. aosp_fugu-userdebug
11. mini_emulator_arm64-userdebug
12. m_e_arm-userdebug
13. mini_emulator_mips-userdebug
14. mini_emulator_x86-userdebug
15. mini_emulator_x86_64-userdebug
16. aosp_flounder-userdebug
17. aosp_angler-userdebug
18. aosp_bullhead-userdebug
19. aosp_hammerhead-userdebug
20. aosp_hammerhead_fp-userdebug
21. aosp_shamu-userdebug
Which would you like? [aosp_arm-eng]
對應關系可以查閱 Selecting a device build
如果提示“Can not find SDK 10.6”,請修改“build/core/combo/mac_version.mk” 中的
mac_sdk_versions_supported := 10.6 10.7 10.8 10.9 10.11
- 啟動編譯
make -j4
四壕曼、刷機
- 指定刷機包的路徑
export ANDROID_PRODUCT_OUT=/Volumes/android/aosp/out/target/product/hammerhead
- 進入 bootloader苏研,并刷機
adb reboot bootloader
fastboot -w flashall