1 搭建环境
Ubuntu22,基于WLS2
bash
sudo apt update && sudo apt upgrade -y
sudo apt install -y git curl python3 build-essential libssl-dev libffi-dev libpython3-dev \
openjdk-17-jdk zip unzip bison flex m4 libncurses5-dev x11proto-core-dev libx11-dev \
lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc ccache
# 配置git基础信息(必须,否则repo会报错)
git config --global user.name "aosp-dev"
git config --global user.email "aosp@example.com"
拉代码
bash
cd ~/aosp
rm -rf .repo
使用清华的镜像。同时repo init 追加 --repo-url 参数 ,绕过默认谷歌地址。
bash
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest \
-b android-14.0.0_r40 \
--repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo \
--no-repo-verify
bash
repo sync -j4 -c --no-tags
bash
jc@LAPTOP-E7FQL6BT:~/qssitest$ repo init --depth=1 --current-branch -u https://git.codelinaro.org/clo/la/la/system/manifest.git -b release -m AU_LINUX_ANDROID_LA.QSSI.14.0.R1.14.00.00.1001.246.00.xml --repo-url=https://git.codelinaro.org/clo/tools/repo.git --repo-branch=qc-stable
Get https://git.codelinaro.org/clo/la/la/system/manifest.git
remote: Enumerating objects: 1461, done.
remote: Counting objects: 100% (1461/1461), done.
remote: Compressing objects: 100% (100/100), done.
remote: Total 1461 (delta 1453), reused 1364 (delta 1361), pack-reused 0 (from 0)
Receiving objects: 100% (1461/1461), 38.08 MiB | 37.00 KiB/s, done.
Resolving deltas: 100% (1453/1453), done.
From https://git.codelinaro.org/clo/la/la/system/manifest
* [new branch] release -> origin/release
Updating files: 100% (3917/3917), done.
Your identity is: jc <chenjiang-c@awear.ai>
If you want to change this, please re-run 'repo init' with --config-name
repo has been initialized in /home/jc/qssitest
一共的空间占用大概是168G。
bash
jc@LAPTOP-E7FQL6BT:~/aosp$ du -sh .
168G .
文件大概如下:
bash
jc@LAPTOP-E7FQL6BT:~/aosp$ ls
Android.bp WORKSPACE bionic bootstrap.bash cts developers device frameworks kernel libnativehelper pdk prebuilts system toolchain
BUILD art bootable build dalvik development external hardware libcore packages platform_testing sdk test tools
2 编译
bash
jc@LAPTOP-E7FQL6BT:~/aosp$ source build/envsetup.sh
jc@LAPTOP-E7FQL6BT:~/aosp$ lunch aosp_x86_64-eng
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=14
PRODUCT_INCLUDE_TAGS=com.android.mainline
TARGET_PRODUCT=aosp_x86_64
TARGET_BUILD_VARIANT=eng
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=x86_64
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-6.18.33.1-microsoft-standard-WSL2-x86_64-Ubuntu-26.04-LTS
HOST_CROSS_OS=windows
BUILD_ID=UD2A.231203.057.A1
OUT_DIR=out
============================================
jc@LAPTOP-E7FQL6BT:~/aosp$ m -j$(nproc)
20:03:43 ************************************************************
20:03:43 You are building on a machine with 15.4GB of RAM
20:03:43
20:03:43 The minimum required amount of free memory is around 16GB,
20:03:43 and even with that, some configurations may not work.
20:03:43
20:03:43 If you run into segfaults or other errors, try reducing your
20:03:43 -j value.
20:03:43 ************************************************************