前言
朋友入手了一臺新款M1的Macbook Pro肤视,成功編譯AOSP奥此,分享一下經驗
MacBook Pro 14寸到腥,M1 Pro 10核心16核圖形處理器,16GB運行內存萌业,1TB硬盤
AOSP on mac
準備工作:
- git
- Python 3
獲取代碼坷襟,切換到清華源
cd ~
mkdir bin/; cd bin/
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo
export PATH=$PATH:~/bin/
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
sudo chown 你的用戶名 /opt/
MacOS X默認的文件系統是不區(qū)分大小寫的,因此需要創(chuàng)建響應的卷生年,然后掛載:
cd /opt/
hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 300g android.img
hdiutil attach android.img.sparseimage -mountpoint android/
mkdir android; cd android
同步代碼:
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-12.0.0_r3
repo sync
編譯:
. build/envsetup.sh
lunch aosp_crosshatch-userdebug
build/soong
下做如下修改:
diff --git a/cc/config/x86_darwin_host.go b/cc/config/x86_darwin_host.go
index b0344af84..ee9f8e746 100644
--- a/cc/config/x86_darwin_host.go
+++ b/cc/config/x86_darwin_host.go
@@ -68,6 +68,7 @@ var (
"10.15",
"11.0",
"11.1",
+ "12.0",
}
darwinAvailableLibraries = append(
總共用時3小時19分婴程,感覺不是很快,這個成績只能是一般般
ulimit -S -n 1024
m
... ...
[ 99% 116263/116280] //frameworks/base/packages/SystemUI:SystemUI r8 [common]
...
Missing class org.jetbrains.annotations.Nullable (referenced from: android.graphics.fonts.Font com.android.keyguard.FontInterpolator$InterpKey.l and 1010 other contexts)
[100% 116280/116280] build out/target/product/crosshatch/obj/PACKAGING/check-all-partition-sizes_intermediates/check_all_partition_sizes.log
#### build completed successfully (03:19:17 (hh:mm:ss)) ####
刷機:
adb reboot bootloader
fastboot flashall -w
遇到的問題
雖然整體編譯過了抱婉,也可以刷機档叔,但是發(fā)現在用一些調試工具的時候有一些莫名其妙的問題。
國外網友的經驗分享
https://www.bilibili.com/video/BV1Fh411874w
1蒸绩,視頻為youtube碼農真實測試M1編譯性能蹲蒲,結果:8個小時∏止螅看起來并沒有為M1設備届搁,還在按照x86-64轉譯運行編譯
2,長遠看Google是否會優(yōu)化M1上的編譯速度呢?答案:否
https://source.android.com/setup/build/requirements
Warning: Building on either Windows or MacOS (as of June 22, 2021) is NOT supported.
購買建議
有錢就買卡睦,沒錢就不買宴胧,合理使用官網14天無理由退貨的規(guī)則。
(這個購買建議也導致這個網友覺得我在諷刺他表锻,然后一言不說就拉黑我了恕齐,我的意思就是你不確定你的工作環(huán)境能否是否適應m芯片,可以買了先試用瞬逊,如果不合適可以直接退显歧,我自己也干過類似的事情,我很不爽為什么一言不合就把我拉黑了确镊,不給我解釋的機會士骤,希望他看到這個評論)