前言
朋友入手了一台新款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默认的文件系统是不区分大小写的,因此需要创建响应的卷,然后挂载:
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
遇到的问题
虽然整体编译过了,也可以刷机,但是发现在用一些调试工具的时候有一些莫名其妙的问题。
国外网友的经验分享
https://www.bilibili.com/video/BV1Fh411874w
1,视频为youtube码农真实测试M1编译性能,结果:8个小时。看起来并没有为M1设备,还在按照x86-64转译运行编译
2,长远看Google是否会优化M1上的编译速度呢?答案:否
https://source.android.com/setup/build/requirements
Warning: Building on either Windows or MacOS (as of June 22, 2021) is NOT supported.
购买建议
有钱就买,没钱就不买,合理使用官网14天无理由退货的规则。
网友评论