MAC AOSP代码编译和下载

文章讲述了如何在Mac上修改文件系统以适应AOSP构建要求,包括通过磁盘工具调整文件系统和使用特定命令行工具下载AOSP源码。在编译过程中,遇到的内存不足和打开文件数限制问题,可以通过修改源代码和设置系统限制来解决,如增加maxfiles和maxproc的值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 前提:首先用mac的磁盘工具将mac的文件系统改一下,不然会报错

20:14:33 Failed to increase file limit: invalid argument
20:15:20 ************************************************************
20:15:20 You are building on a case-insensitive filesystem.
20:15:20 Please move your source tree to a case-sensitive filesystem.
20:15:20 ************************************************************
20:15:20 Case-insensitive filesystems not supported

修改如下:

 或者用命令修改也可以

2. 配置aosp环境 & 下载代码

mkdir AOSP && cd AOSP/
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod a+x ~/bin/repo
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-13.0.0_r1
repo sync

下载速度取决于网络,我下载了4个小时

3. 编译

首先编译可能遇到问题

19:08:29 You are building on a machine with 8GB of RAM
19:08:29 
19:08:29 The minimum required amount of free memory is around 16GB,
19:08:29 and even with that, some configurations may not work.
19:08:29 
19:08:29 If you run into segfaults or other errors, try reducing your
19:08:29 -j value.

解决此报错问题的方法是修改编译配置

vi build/soong/ui/build/build.go

搜索报错的内容,将16改成你的电脑内存配置即可

source build/envsetup.sh
lunch aosp_flame-userdebug
cd external/tinyxml2/
mm

如果遇到too many open files,主要原因是打开了太多的文件,系统资源吃紧,看一下系统

launchctl limit

在 /Library/LaunchDaemos 目录下,新建两个文件:limit.maxfiles.plist 和 limit.maxproc.plist,并且修改两个文件的用户为 root,内容如下,添加完后重启电脑生效:

limit.maxfiles.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
    <dict>
      <key>Label</key>
        <string>limit.maxfiles</string>
      <key>ProgramArguments</key>
        <array>
          <string>launchctl</string>
          <string>limit</string>
          <string>maxfiles</string>
          <string>65536</string>
          <string>65536</string>
        </array>
      <key>RunAtLoad</key>
        <true/>
      <key>ServiceIPC</key>
        <false/>
    </dict>
</plist>

limit.maxproc.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
    <dict>
      <key>Label</key>
        <string>limit.maxproc</string>
      <key>ProgramArguments</key>
        <array>
          <string>launchctl</string>
          <string>limit</string>
          <string>maxproc</string>
          <string>2048</string>
          <string>2048</string>
        </array>
      <key>RunAtLoad</key>
        <true />
      <key>ServiceIPC</key>
        <false />
    </dict>
</plist>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值