在wsl 2中编译自己的魔趣(mokee) ROM
1.安装wsl2
a.在windows 10 系统中启用wsl2(只能是wsl2,wsl1 会编译失败), 并商店中下载ubuntu镜像,商店默认安装位置为C:\Program Files\WindowsApps,考虑到编译需要100多G空间,需要把app移动到其他盘.
用管理员权限打开cmd
1 :: 切换到目录中 2 c:\Program Files\WindowsApps> cd /d "C:\Program Files\WindowsApps"
3 :: 查找文件夹名字
4 c:\Program Files\WindowsApps>dir | findstr Ubuntu20
5 2022/02/07 16:35 <DIR> CanonicalGroupLimited.Ubuntu20.04onWindows_2004.2021.825.0_neutral_split.scale-100_79rhkp1fndgsc
6 2022/02/07 16:35 <DIR> CanonicalGroupLimited.Ubuntu20.04onWindows_2004.2021.825.0_neutral_~_79rhkp1fndgsc
7 2022/02/07 16:35 <DIR> CanonicalGroupLimited.Ubuntu20.04onWindows_2004.2021.825.0_x64__79rhkp1fndgsc
8
9 xcopy CanonicalGroupLimited.Ubuntu20.04onWindows_2004.2021.825.0_x64__79rhkp1fndgsc e:\wsl /E/H/C/I
b.直接双击运行ubuntu2004.exe,
2.准备环境
安装环境
https://source.android.google.cn/setup/initializing?hl=zh-cn
aosp编译流程
https://source.android.google.cn/setup/building?hl=zh-cn
3.由于大部分库都在墙外,设置代理
1 #repo设置proxy 2 export http_proxy=http://192.168.1.60:8080 3 export https_proxy=https://192.168.1.60:8080 4 #Git设置proxy 5 git config --global http.proxy http://192.168.1.60:8080 6 git config --global https.proxy http://192.168.1.60:8080 7 8 git config --global --unset http.proxy 9 git config --global --unset https.proxy
4.下载代码,时间比较长.
1 $ mkdir ~/mokee 2 $ git config --global user.email "your@email.address" 3 $ git config --global user.name “Your Name” 4 $ cd ~/mokee 5 6 $ repo init -u https://github.com/MoKee/android -b mkq-mr1 --depth 1 7 $ repo sync -j4
5.执行breakfast.
1 DESKTOP-AIAM0DF:~/mokee$ breakfast 2 You're building on Linux 3 4 Lunch menu... pick a combo: 5 1. aosp_arm-eng 6 2. aosp_arm64-eng 7 3. aosp_car_arm-userdebug 8 4. aosp_car_arm64-userdebug 9 5. aosp_car_x86-userdebug 10 6. aosp_car_x86_64-userdebug 11 7. aosp_x86-eng 12 8. aosp_x86_64-eng 13 9. car_x86_64-userdebug 14 10. m_e_arm-userdebug 15 11. mini_emulator_arm64-userdebug 16 12. mini_emulator_x86-userdebug 17 13. mini_emulator_x86_64-userdebug 18 14. mokee_arm-userdebug 19 15. mokee_arm64-userdebug 20 16. mokee_dumpling-eng 21 17. mokee_dumpling-user 22 18. mokee_dumpling-userdebug 23 19. mokee_x86-userdebug 24 20. mokee_x86_64-userdebug 25 21. qemu_trusty_arm64-userdebug 26 22. uml-userdebug 27 28 Which would you like? [aosp_arm-eng] ^C
如果列表中没有 mokee_dumpling-userdebug,
则往.repo/manifests/default.xml中添加
怎么知道name="MoKee/android_device_oneplus_dumpling", 其实是直接在 https://github.com/MoKee 中搜索dumpling,根据xml格式自己添加的,
再次执行repo sync
6.执行 lunch mokee_dumpling-userdebug
7.执行 mka bacon
等待漫长的编译过程, 我16G内存,占用了大约12G.所以内存最好16G以上.
中间碰到几个错误,google下都解决了.
碰到的一些错误.
错误 cmd: unknown variable '$(PATH_OVERRIDE_SOONG)'
解决 breakfast
repo sync
mkbacon
编译Android时报错:error while loading shared libraries: libncurses.so.5: cannot open shared object file:
解决方式
https://blog.csdn.net/druieam/article/details/106818875
参考文档
How To Port CyanogenMod/LineageOS Android To Your Own Device
Build for dumpling
编译属于你自己的 Sultanized MoKee
小米8(Dipper)编译魔趣MK100全流程记录