MacOSX 11.6 下编译 AOSP android11 系统源代码

2,081 阅读1分钟

简介

编译主要参考:Establishing a Build Environment ,其中要点:

  • Important:  Platform development on MacOS isn't supported as of June 22, 2021.
  • 官方建议 Ubuntu18.04
  • 尽量使用 Ubuntu18.04!!!
  • 尽量使用 Ubuntu18.04!!!
  • 尽量使用 Ubuntu18.04!!!

环境:

macOS Big Sur 11.6 (20G165)
MacBook Pro (15-inch, 2018)
2.9 GHz 六核Intel Core i9
32 GB 2400 MHz DDR4
源码及构建用了 将近300GB(261GB)

快速命令

清华镜像

repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-11.0.0_r3
repo sync

source build/envsetup.sh
lunch aosp_x86_64-eng
make SELINUX_IGNORE_NEVERALLOWS=true -j6
emulator  //可以看到 可运行Android 模拟器

问题及方法

MacOSX 特别是问题多多,可参考 yongfengnice 的 mac下编译android系统源代码以及编译指定模块

  1. 文件描述符限制
  2. 没有对应支持的sdk版本;10.10-10.15, 而本机是12.0 修改build/soong/cc/config/x86_darwin_host.go 完成的;
  3. PAGE_SIZE 问题:添加PAGE_SIZE宏定义。 #define PAGE_SIZE 4096
system/core/base/cmsg.cpp:78:21: error: use of undeclared identifier 'PAGE_SIZE' 
if (cmsg_space >= PAGE_SIZE) {
  1. python2/3兼容mac的问题
external/python/cpython2/Modules/getpath.c:414:50: 
error: incompatible pointer types passing 'unsigned long *' to parameter of type 'uint32_t *' (aka 'unsigned int *') [-Werror,-Wincompatible-pointer-types]

方法:

external/python/cpython2/Modules/getpath.c 编辑getpath.c文件,添加头文件引入。 
#include <AvailabilityMacros.h>
  1. 测试到放弃 vagrant/virutualbox 下的 Ubuntu18.04;
1. shared-folder太卡,
2. Failed to listen for path logs: listen unix out/.path_interposer_log: bind: operation not supported

待办

  1. 问题:没有对应支持的sdk版本:下载MacOSX-SDKs的10.14,10.15, 没生效

杂杂碎

  • 目前版本使用是:android-11.0.0_r3
  • 对于MacBookPro整体还是很舒服,AOSP放弃MacOS是为何?
  • 为了能在MBP看代码跟踪,在macOS进行AOSP编译;
  • 设备的AOSP,准备只在Ubuntu18.04 的编译服务进行