PixelOS 15 编译
也是重拾老本行了
代码在有代理下拉取
本文不是编译教程,不会介绍工具链下载,代码下载
如有疑问,自行查阅官方文档
本文只写笔者关心的部分
diff 有做删行
为什么是PixelOS
,因为它带GMS。官方给了一份参考,它是A13时期的,官方只说过时,没说什么时候继续完善
https://blog.pixelos.net/docs/JoinTheTeam/BuildingPixelOS
接下来是项目仓库,其中的README
文档会告知如何下载,在此不再赘述
https://github.com/PixelOS-AOSP/manifest
即使在有代理的情况下也不能保证连接质量
所以使用国内镜像源进行加速下载
以下链接会告知如何配置
此处使用清华大学提供的镜像服务
https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/
https://mirrors.tuna.tsinghua.edu.cn/help/lineageOS/
编译Android
,AOSP
代码必不可少,不然编个锤子
说是PixelOS
,其中引用了LineageOS
的仓库,所以也为LineageOS
仓库配置镜像
在初始化仓库完毕以后
需在.repo/manifests
目录下做如下修改,以配置镜像
diff --git a/default.xml b/default.xml
--- a/default.xml
+++ b/default.xml
<manifest>
<remote name="aosp"
- fetch="https://android.googlesource.com"
+ fetch="https://mirrors.tuna.tsinghua.edu.cn/git/AOSP"
review="https://android-review.googlesource.com/" />
<default revision="refs/tags/android-15.0.0_r32"
remote="aosp"
diff --git a/snippets/lineage.xml b/snippets/lineage.xml
--- a/snippets/lineage.xml
+++ b/snippets/lineage.xml
<remote name="LineageOS"
- fetch="https://github.com/"
+ fetch="https://mirrors.tuna.tsinghua.edu.cn/git/lineageOS/"
解决同步gms
仓库时找不到fifteen
分支
diff --git a/snippets/custom.xml b/snippets/custom.xml
--- a/snippets/custom.xml
+++ b/snippets/custom.xml
- <project path="vendor/gms" name="vendor_gms" clone-depth="1" remote="PixelOS-Gitlab" />
+ <project path="vendor/gms" name="vendor_gms-15" clone-depth="1" remote="PixelOS-Gitlab" />
修改完成以后同步代码
记录一下遇到的问题
因部分仓库克隆中断,导致最后的检出环节出现问题
在.repo
目录下,需要关注 project-objects
、 projects
两个文件夹
这两个目录与同步代码有关,两者目录结构不完全一致,
还有.repo
的上级目录,也就是代码同步的目录,也是需要操作的部分
例如
先根据报错找到出错的仓库
其中有提示,使用-j1 --fail-fast
可以在第一次错误时退出
检出时出现的问题,所以我们直接检出,组合命令:
repo sync -l -j1 --fail-fast
就可以定位第一个出现问题的仓库
笔者定位的还是这个仓库,所以不上其他图了
platform/prebuilts/rust
在.repo/project-objects
顺藤摸瓜找到rust
按下del
给它删了
.repo/projects
目录下并没有platform
目录,但是有prebuilts
目录
在其中找到了rust.git
二者对应关系可参考.repo/manifest/default.xml
你会找到答案的
最后回到非.repo
目录,在其中的prebuilts
目录下有rust
文件夹
找到这三个文件夹,给它删除
再看看.repo/manifest/default.xml
?
之后,只同步这个仓库
repo sync -n platform/prebuilts/rust
在同步完成以后,
repo sync -l -j1 --fail-fast
再次检出
很遗憾还是它
在源码同步目录,非.repo
目录,也就是上文最后一个提到的文件夹删除
再次重新检出
顺利完成
最后再repo sync
一次,若不再报错,即同步完成
下面根据特定设备,下载所需文件进行编译
根据官方文档的意思,被官方支持的设备应该可以直接lunch
后直接下载所需文件
但是笔者的设备不在该项目官方支持列表中,但Xiaomi MIX2S
有 LineageOS
官方维护,所以使用LineageOS
提供的设备树文件进行编译
在此感谢Xiaomi MIX2S
LineageOS
官方维护者所做的工作
Xiaomi MIX2S
代号 polaris
我们可以根据设备代号查找设备树文件
例如查找到的仓库
https://github.com/LineageOS/android_device_xiaomi_polaris/
然后根据 lineage.dependencies
[
{
"repository": "android_device_xiaomi_sdm845-common",
"target_path": "device/xiaomi/sdm845-common"
}
]
查找相关仓库,一并下载下来
我们组合命令
git clone https://github.com/LineageOS/android_device_xiaomi_sdm845-common -b lineage-22.2 device/xiaomi/sdm845-common --depth=1
LineageOS 22.2
与 PixelOS 15
在AOSP
部分,二者都是 android-15.0.0_r32
所以采用lineage-22.2
分支
然后再次查看android_device_xiaomi_sdm845-common
仓库中的dependencies
文件,继续下载其他所需文件
关注最后一个
git clone https://github.com/PixelOS-AOSP/hardware_xiaomi -b fifteen hardware/xiaomi --depth=1
采用PixelOS
的仓库,因为它提供了,所以用它的
最后的--depth=1
意思是拉取最新的一次提交,历史提交不必拉取,除非你需要
由于PixelOS
与LineageOS
的目录结构存在差异,所以对其中的路径做出一些必要的修改
android_device_xiaomi_polaris
目录下
diff --git a/AndroidProducts.mk b/AndroidProducts.mk
--- a/AndroidProducts.mk
+++ b/AndroidProducts.mk
PRODUCT_MAKEFILES := \
- $(LOCAL_DIR)/lineage_polaris.mk
+ $(LOCAL_DIR)/aosp_polaris.mk
diff --git a/lineage_polaris.mk b/aosp_polaris.mk
rename from lineage_polaris.mk
rename to aosp_polaris.mk
--- a/lineage_polaris.mk
+++ b/aosp_polaris.mk
-$(call inherit-product, vendor/lineage/config/common_full_phone.mk)
+$(call inherit-product, vendor/aosp/config/common_full_phone.mk)
# Device identifier. This must come after all inclusions.
PRODUCT_NAME := lineage_polaris
android_device_xiaomi_sdm845-common
目录下
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
index 29e0b3a..791bcb2 100644
--- a/BoardConfigCommon.mk
+++ b/BoardConfigCommon.mk
- vendor/lineage/config/device_framework_matrix.xml
+ vendor/aosp/config/device_framework_matrix.xml
-include vendor/lineage/config/BoardConfigReservedSize.mk
+include vendor/aosp/config/BoardConfigReservedSize.mk
在设备目录下,执行extract-files.py
提取所需blob
文件,如何提取,LineageOS wiki
中有答案,请自行查阅
在完成设备树修改与提取设备blob
文件后
在代码根目录
. build/envsetup.sh
lunch aosp_polaris-bp1a-userdebug
mka bacon
若对命令有疑问,请自行查阅官方仓库文档
开始编译,起飞
历经两个半小时,编译完成
刷入