前言
为什么写这本书,本人一生时间可以说都贡献在嵌入式产品领域,见证了中国嵌入式产品的高速发展时期。你们可以叫我豆芽哥,我憧憬有一个人人知晓的豆芽科技公司,不过目前它还住在我心里,呵呵!我希望通过这本书帮助那些需要的人,同时也希望通过这本书结交志同道合的战友。我将通过编写豆芽系列书籍,带大家从基本技能:软件开发、硬件设计、测试验证、产品管理、公司运营,走向行业领域:智能手机、智能汽车、智能机器人三大产品。
《ASOP 豆芽教程》用于AOSP项目的讲解,掌握如何定制安卓操作系统,作为你设计基于安卓系统的嵌入式产品的基础,比如你自己的手机产品,你自己的汽车智能座舱中控台。
预备知识
out目录在什么时候创建
在lunch时创建,具体是在准备好 platform/build/blueprint 项目时,执行lunch就会创建空的out目录。这说明了,准备lunch环境的过程:构建框架->工具集->发布配置->产品->模块 中,当完成构建框架准备时,lunch就会开始创建out目录,作为后续工具集运行的可输出目录。
编译完查看所有应用的发布配置值文件
在 out/soong/release-config/ 下的:
/release_config-<你的lunch目标,如:aosp_cf_x86_64_phone-trunk_staging >_staging.vars
如何从已同步完成的aosp迁移
同步完成的.repo目录:
关键目录:project-objects projects
project-objects : 同步下载第一次存放位置,目录结构同远端项目实际目录:
projects:本地迁出目录缓存,目录结构同本地aosp目录
重点:
需要迁移时,先同步一个项目,比如 build。然后将待迁移aosp的project-objects覆盖迁移位置同样目录即可。然后就可以增量式的repo sync了。
ABI
在Android中,ABI(Application Binary Interface)用于描软件与底层硬件架构之间的接口规范。Android设备通常基于不同的处理器架构,例如ARM、ARM64、x86、x86_64等。每种架构都有自己的ABI规范,因此同一个应用程序可能需要针对不同的ABI进行编译,以确保在不同的设备上能够正确运行。
常见的Android ABI包括:
armeabi-v7a:基于ARMv7架构的32位处理器,支持大多数现代Android设备。
arm64-v8a:基于ARMv8-A架构的64位处理器,提供更好的性能和内存管理。
x86:基于x86架构的32位处理器,用于模拟器和某些Intel或AMD架构的Android设备。
x86_64:基于x86_64架构的64位处理器,提供更好的性能和内存管理,用于模拟器和一些新型Android设备。
VNDK
官网:供应商原生开发套件 (VNDK) 概览 | Android Open Source Project
供应商原生开发套件 (VNDK) 是一组库,可供供应商分区或产品分区中的其他库或二进制文件在 dlopen 运行时期间使用。
kemint
Keymint(自Keymaster 5.0起)是Android平台的关键安全组件,专注于提供高级别的秘钥管理和加密服务。
参考:https://zhuanlan.zhihu.com/p/696593176
APEX更新包
APEX格式将一些二进制文件、共享库等系统级组件打包到APEX文件中,用于更新和替换设备上的关键系统组件,而无需进行完整的系统更新,旨在优化系统更新过程,提高系统的模块化和可维护性。
repo manifest 文件格式
创建软连接:
path: 基于源码根目录,本地创建的目录
name: project 名
linkfile: 创建软连接动作, 参数src:基于项目根目录(platform/build/)的被链接文件, dest:软链接文件
<project path="build/make" name="platform/build" groups="pdk,sysui-studio" >
<linkfile src="CleanSpec.mk" dest="build/CleanSpec.mk" />
<linkfile src="buildspec.mk.default" dest="build/buildspec.mk.default" />
<linkfile src="core" dest="build/core" />
<linkfile src="envsetup.sh" dest="build/envsetup.sh" />
<linkfile src="target" dest="build/target" />
<linkfile src="tools" dest="build/tools" />
</project>
遇到的问题
搭建环境类
让 repo sync 及时退出
repo sync -j1 --fail-fast -c project 如:
repo sync -j1 --fail-fast -c platform/prebuilts/abi-dumps/vndk
安装repo
安装前:
第三条下载秘钥,开启VPN时可能失败,关闭
在home目录创建bin
执行:
export REPO=$(mktemp /tmp/repo.XXXXXXXXX)
curl -o ${REPO} https://storage.googleapis.com/git-repo-downloads/repo
gpg --recv-keys 8BB9AD793E8E6153AF0F9A4416530D5E920F5C65
curl -s https://storage.googleapis.com/git-repo-downloads/repo.asc | gpg --verify - ${REPO} && install -m 755 ${REPO} ~/bin/repo
编译产出
out目录下的点文件
lunch时out目录生成了隐藏文件夹:
heyang@MSI:~/aosp/main/out$ tree -a -A
.
├── .lock_dumpvars-build.trace.gz
├── .lock_dumpvars-error.log
├── .lock_dumpvars-soong.log
├── .lock_dumpvars-verbose.log.gz
├── .microfactory_Linux.lock
├── .microfactory_Linux_hash
├── .microfactory_Linux_intermediates
│ ├── github.com-google-blueprint-microfactory
│ │ └── github.com
│ │ └── google
│ │ └── blueprint
│ │ ├── microfactory.a
│ │ └── microfactory.a.hash
│ ├── main
│ │ ├── main.a
│ │ └── main.a.hash
│ └── src
│ └── microfactory.go
......
......
......
out目录下的 soong_ui
由go编译生成,源码在
heyang@MSI:~/aosp/main/build/soong/cmd/soong_ui$ tree
.
├── Android.bp
└── main.go
1 directory, 2 files
从platform/build项目开始分析全局
提前总结:
要让lunch可工作,需先按以下路径做好准备:
build->soong->blueprint->工具集->发布配置->产品->模块
再收敛为:构建框架->工具集->发布配置->产品->模块。
先拉build项目,开始旅程
提示:关于AOSP基本开发环境的搭建,可参考官网:https://source.android.com/docs/setup/start/requirements
repo sync -c platform/build
一边编译一边分析
source 出现警告
暂时忽略
heyang@MSI:~/aosp/main$ source build/envsetup.sh
Warning: completion file /home/heyang/aosp/main/packages/modules/adb/adb.bash not found
Warning: completion file /home/heyang/aosp/main/system/core/fastboot/fastboot.bash not found
Warning: completion file /home/heyang/aosp/main/tools/asuite/asuite.sh not found
直接lunch报错
原因:没拉soong项目
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
-bash: build/soong/soong_ui.bash: No such file or directory
out目录变化:
没建out目录
拉 platform/build/soong 项目
heyang@MSI:~/aosp/main$ repo sync -c platform/build/soong
Fetching: 100% (1/1), done in 26.150s
Updating files: 100% (1235/1235), done.
Checking out: 100% (1/1), done in 6.090s
repo sync has finished successfully.
顶级Android.bp文件
heyang@MSI:~/aosp/main$ ll
total 16
drwxr-xr-x 4 heyang heyang 4096 Dec 20 21:02 ./
drwxr-xr-x 3 heyang heyang 4096 Dec 20 18:19 ../
drwxr-xr-x 7 heyang heyang 4096 Dec 20 18:51 .repo/
lrwxrwxrwx 1 heyang heyang 19 Dec 20 21:02 Android.bp -> build/soong/root.bp
lrwxrwxrwx 1 heyang heyang 26 Dec 20 21:02 bootstrap.bash -> build/soong/bootstrap.bash*
drwxr-xr-x 4 heyang heyang 4096 Dec 20 21:02 build/
继续lunch继续报错
原因:没拉blueprint项目
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
/home/heyang/aosp/main/build/soong/scripts/microfactory.bash: line 66: /home/heyang/aosp/main/build/blueprint/microfactory/microfactory.bash: No such file or directory
out目录变化:
没建out目录
拉 platform/build/blueprint 项目
heyang@MSI:~/aosp/main$ repo sync -c platform/build/blueprint
Fetching: 100% (1/1), done in 4.607s
Updating files: 100% (151/151), done.
Checking out: 100% (1/1), done in 3.417s
repo sync has finished successfully.
继续lunch继续报错
原因:没拉 platform/prebuilts/go/linux-x86 项目
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
/home/heyang/aosp/main/build/blueprint/microfactory/microfactory.bash: line 63: cd: /home/heyang/aosp/main/prebuilts/go/linux-x86/: No such file or directory
/home/heyang/aosp/main/build/blueprint/microfactory/microfactory.bash: line 63: /home/heyang/aosp/main/prebuilts/go/linux-x86//bin/go: No such file or directory
out目录变化:
建立out目录,但为空目录
拉platform/prebuilts/go/linux-x86 项目
heyang@MSI:~/aosp/main$ repo sync -c platform/prebuilts/go/linux-x86
Fetching: 100% (1/1), done in 3.353s
Updating files: 100% (14130/14130), done.
Checking out: 100% (1/1), done in 3m13.285s
repo sync has finished successfully.
继续lunch继续报错
原因:缺少 platform/external/golang-protobuf 项目
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
Failed to find deps of android/soong/cmd/soong_ui: Error parsing directory "/home/heyang/aosp/main/external/golang-protobuf/proto": open /home/heyang/aosp/main/external/golang-protobuf/proto: no such file or directory
exit status 1
out目录变化:
heyang@MSI:~/aosp/main/out$ tree
.
└── microfactory_Linux
1 directory, 1 file
拉取platform/external/golang-protobuf 项目
heyang@MSI:~/aosp/main$ repo sync -c platform/external/golang-protobuf
Fetching: 100% (1/1), done in 4.786s
Updating files: 100% (451/451), done.
Checking out: 100% (1/1), done in 4.905s
repo sync has finished successfully.
继续lunch继续报错
原因:没拉 platform/external/starlark-go 项目
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
Failed to find deps of rbcrun/rbcrun: Error parsing directory "/home/heyang/aosp/main/external/starlark-go/starlark": open /home/heyang/aosp/main/external/starlark-go/starlark: no such file or directory
out目录变化:
heyang@MSI:~/aosp/main$ tree out/
out/
├── microfactory_Linux
├── mk2rbc
└── soong_ui
1 directory, 3 files
拉 platform/external/starlark-go 项目
heyang@MSI:~/aosp/main$ repo sync -c platform/external/starlark-go
Fetching: 100% (1/1), done in 4.856s
Updating files: 100% (94/94), done.
Checking out: 100% (1/1), done in 3.874s
repo sync has finished successfully.
继续lunch继续报错
原因:没拉 platform/prebuilts/build-tools 项目
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
22:28:05 Build sandboxing disabled due to nsjail error.
22:28:05 Failed to run dumpvars: fork/exec prebuilts/build-tools/linux-x86/bin/ckati: no such file or directory
out目录变化:
heyang@MSI:~/aosp/main$ tree out/
out/
├── Android.mk
├── CleanSpec.mk
├── build_date.txt
├── dumpvars-build.trace.1.gz
├── dumpvars-build.trace.gz
├── dumpvars-error.1.log
├── dumpvars-error.log
├── dumpvars-soong.1.log
├── dumpvars-soong.log
├── dumpvars-soong_metrics
├── dumpvars-verbose.log.1.gz
├── dumpvars-verbose.log.gz
├── file_name_tag.txt
├── microfactory_Linux
├── mk2rbc
├── ninja_build
├── rbcrun
├── release-config
├── soong
│ └── build_number.txt
└── soong_ui
2 directories, 20 files
拉取 platform/prebuilts/build-tools
有点大,拉很久
heyang@MSI:~/aosp/main$ repo sync -c platform/prebuilts/build-tools
Fetching: 100% (1/1), done in 3.423s
Updating files: 100% (6817/6817), done.
Checking out: 100% (1/1), done in 1h24m48.537s
repo sync has finished successfully.
这个仓库和其他仓库不一样,日志很少,只有一条,且显示了一个grafted
heyang@MSI:~/aosp/main/prebuilts/build-tools$ git log
commit 19dce33cfd5c17b965f7d460597049676f29913b (grafted, HEAD, m/main, aosp/main)
Author: Cole Faust <colefaust@google.com>
Date: Tue Dec 17 11:18:58 2024 -0800
Update path to SOONG_HOST_OUT
Bug: 383892968
Test: OUT_DIR=out ./prebuilts/build-tools/build-prebuilts.sh --skip-asan --skip-go --skip-soong-tests
Change-Id: I6b5665d220a443dda094595de5e6937b3ff2da5d
继续lunch继续报错
原因:没拉 platform/build/release 项目
重点:这里开始应用AOSP新特性发布配置,说着这里开始和AOSP有些相关性的操作了。之前到build-tools的准备应该都是些基本的环境准备。
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
panic: stat vendor/google/release/release_config_map.textproto: no such file or directory
goroutine 1 [running]:
main.main()
build/soong/cmd/release_config/release_config/main.go:71 +0x14c5
In file included from build/make/core/config.mk:406:
In file included from build/make/core/envsetup.mk:51:
build/make/core/release_config.mk:142: error: release-config failed to run.
10:27:52 dumpvars failed with: exit status 1
out目录:
相比多了 release-config.out
heyang@MSI:~/aosp/main/out$ tree
.
├── Android.mk
├── CleanSpec.mk
├── build_date.txt
├── dumpvars-build.trace.1.gz
├── dumpvars-build.trace.gz
├── dumpvars-error.1.log
├── dumpvars-error.log
├── dumpvars-soong.1.log
├── dumpvars-soong.log
├── dumpvars-soong_metrics
├── dumpvars-verbose.log.1.gz
├── dumpvars-verbose.log.gz
├── file_name_tag.txt
├── microfactory_Linux
├── mk2rbc
├── ninja_build
├── rbcrun
├── release-config
├── release-config.out
├── soong
│ └── build_number.txt
└── soong_ui
2 directories, 21 files
拉取 platform/build/release
heyang@MSI:~/aosp/main$ repo sync -c platform/build/release
Fetching: 100% (2/2), done in 2m5.766s
Updating files: 100% (5417/5417), done.
Checking out: 100% (1/1), done in 6.984s
repo sync has finished successfully.
继续lunch继续报错
原因:没拉取 device/google/cuttlefish 项目
重点:这里开始加载产品配置了,产品配置是通过 product_config.mk 去查找的。AOSP产品配置文件存放在 device目录,至此还没拉取过device目录的内容。device 下有多个产品配置项目,lunch不带参数默认target是:aosp_cf_x86_64_phone-trunk_staging-eng,产品名是 aosp_cf_x86_64_phone。在线源码查找 aosp_cf_x86_64_phone 后得知 应该拉取 device/google/cuttlefish 项目。
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
In file included from build/make/core/config.mk:406:
In file included from build/make/core/envsetup.mk:351:
build/make/core/product_config.mk:226: error: Cannot locate config makefile for product "aosp_cf_x86_64_phone".
18:54:12 dumpvars failed with: exit status 1
在线源码查找 aosp_cf_x86_64_phone
out目录:
相比 release-config 目录多了很多内容,可能是发布配置被解析完成
heyang@MSI:~/aosp/main$ tree out/
out/
├── Android.mk
├── CleanSpec.mk
├── build_date.txt
├── dumpvars-build.trace.1.gz
├── dumpvars-build.trace.gz
├── dumpvars-error.1.log
├── dumpvars-error.log
├── dumpvars-soong.1.log
├── dumpvars-soong.log
├── dumpvars-soong_metrics
├── dumpvars-verbose.log.1.gz
├── dumpvars-verbose.log.gz
├── file_name_tag.txt
├── microfactory_Linux
├── mk2rbc
├── ninja_build
├── rbcrun
├── release-config
├── release-config.out
├── soong
│ ├── build_number.txt
│ └── release-config
│ ├── all_release_configs-.json
│ ├── all_release_configs-.pb
│ ├── all_release_configs-.textproto
│ ├── all_release_configs-aosp_cf_x86_64_phone.json
│ ├── all_release_configs-aosp_cf_x86_64_phone.pb
│ ├── all_release_configs-aosp_cf_x86_64_phone.textproto
│ ├── build_flags_com.android.wifi.json
│ ├── build_flags_host.json
│ ├── build_flags_product.json
│ ├── build_flags_system.json
│ ├── build_flags_system_ext.json
│ ├── build_flags_vendor.json
│ ├── inheritance_graph-.dot
│ ├── inheritance_graph-aosp_cf_x86_64_phone.dot
│ ├── release_config--.varmk
│ ├── release_config--trunk_staging.varmk
│ └── release_config-aosp_cf_x86_64_phone-trunk_staging.varmk
└── soong_ui
3 directories, 38 files
拉取 device/google/cuttlefish
拉的挺久
heyang@MSI:~/aosp/main$ repo sync -c device/google/cuttlefish
Fetching: 100% (1/1), done in 36m37.347s
Updating files: 100% (1901/1901), done.
Checking out: 100% (1/1), done in 1m0.256s
repo sync has finished successfully.
继续lunch继续报错
原因:没拉 platform/packages/modules/Virtualization 项目
小知识:下面make错误,从config.mk的406行开始到aosp_cf.mk的42行报错。
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
In file included from build/make/core/config.mk:406:
In file included from build/make/core/envsetup.mk:351:
In file included from build/make/core/product_config.mk:234:
device/google/cuttlefish/vsoc_x86_64/phone/aosp_cf.mk:42: error: packages/modules/Virtualization/apex/product_packages.mk does not exist..
07:08:51 dumpvars failed with: exit status 1
out 目录:
相比 无变化
拉取 platform/packages/modules/Virtualization
至此开始准备模块,虚拟化模块是第一个配置的
heyang@MSI:~/aosp/main$ repo sync -c platform/packages/modules/Virtualization
Fetching: 100% (1/1), done in 7.544s
Updating files: 100% (1214/1214), done.
Checking out: 100% (1/1), done in 2m2.422s
repo sync has finished successfully.
继续lunch继续报错
原因:没拉 platform/frameworks/native 项目
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
In file included from build/make/core/config.mk:406:
In file included from build/make/core/envsetup.mk:351:
In file included from build/make/target/product/window_extensions.mk:26:
device/google/cuttlefish/shared/phone/device_vendor.mk:26: error: frameworks/native/build/phone-xhdpi-2048-dalvik-heap.mk does not exist..
11:01:12 dumpvars failed with: exit status 1
out 目录
相比 无变化
拉 platform/frameworks/native
这里开始准备架构中的 System Services, 比如 SurfaceFlinger,这个项目都是C++代码
heyang@MSI:~/aosp/main$ repo sync -c platform/frameworks/native
Fetching: 100% (1/1), done in 25.539s
Updating files: 100% (3869/3869), done.
Checking out: 100% (1/1), done in 10.287s
repo sync has finished successfully.
继续lunch继续报错
原因:没拉 platform/system/core 项目
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
In file included from build/make/core/config.mk:406:
In file included from build/make/core/envsetup.mk:351:
In file included from device/google/cuttlefish/shared/consumerir/device_vendor.mk:16:
device/google/cuttlefish/shared/device.mk:426: error: system/core/trusty/keymint/trusty-keymint.mk does not exist..
12:19:03 dumpvars failed with: exit status 1
out目录:
相比无变化
拉 platform/system/core
本层对应架构中的System Services and Daemon, 是内核之上的核心代码,有进程也有库。
heyang@MSI:~/aosp/main$ repo sync -c platform/system/core
Fetching: 100% (1/1), done in 24.383s
Updating files: 100% (1856/1856), done.
Checking out: 100% (1/1), done in 5.431s
repo sync has finished successfully.
继续lunch继续报错
原因:没拉 kernel/prebuilts/common-modules/virtual-device/6.6/x86-64 项目
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
grep: kernel/prebuilts/common-modules/virtual-device/6.6/x86-64/nd_virtio.ko: No such file or directory
In file included from build/make/core/config.mk:406:
In file included from build/make/core/envsetup.mk:368:
build/make/core/board_config.mk:999: error: VNDK version 30 not found.
12:49:09 dumpvars failed with: exit status 1
out目录:
没变化
拉 kernel/prebuilts/common-modules/virtual-device/6.6/x86-64
至此,开始准备内核部分了,AOSP这里使用的是预编译号的内核文件。所以在编译AOSP源码时,内核部分是属于二进制集成的。
heyang@MSI:~/aosp/main$ repo sync -c kernel/prebuilts/common-modules/virtual-device/6.6/x86-64
Fetching: 100% (1/1), done in 2.148s
Updating files: 100% (44/44), done.
Checking out: 100% (1/1), done in 5.325s
repo sync has finished successfully.
继续lunch继续报错
原因:没拉 platform/prebuilts/vndk/v30
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
In file included from build/make/core/config.mk:406:
In file included from build/make/core/envsetup.mk:368:
build/make/core/board_config.mk:999: error: VNDK version 30 not found.
13:14:50 dumpvars failed with: exit status 1
拉取 platform/prebuilts/vndk/v30
有点久,另外还有其他版本:
heyang@MSI:~/aosp/main$ repo sync -c platform/prebuilts/vndk/v30
Fetching: 100% (2/2), done in 4.629s
Checking out: 100% (1/1), done in 0.001s
repo sync has finished successfully.
继续lunch继续报错
原因:没拉 platform/prebuilts/vndk/v31
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
In file included from build/make/core/config.mk:406:
In file included from build/make/core/envsetup.mk:368:
build/make/core/board_config.mk:999: error: VNDK version 31 not found.
11:12:24 dumpvars failed with: exit status 1
out目录:
无变化
拉 platform/prebuilts/vndk/v31
heyang@MSI:~/aosp/main$ repo sync -c platform/prebuilts/vndk/v31
Fetching: 100% (1/1), done in 1.676s
Checking out: 100% (1/1), done in 0.001s
repo sync has finished successfully.
继续lunch继续报错:
原因: 没拉 platform/prebuilts/vndk/v32
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
In file included from build/make/core/config.mk:406:
In file included from build/make/core/envsetup.mk:368:
build/make/core/board_config.mk:999: error: VNDK version 32 not found.
12:13:36 dumpvars failed with: exit status 1
拉取 platform/prebuilts/vndk/v32
heyang@MSI:~/aosp/main$ repo sync -c platform/prebuilts/vndk/v32
Fetching: 100% (1/1), done in 2.448s
Updating files: 100% (18387/18387), done.
Checking out: 100% (1/1), done in 1.502s
repo sync has finished successfully.
继续lunch继续报错
原因:没拉 platform/prebuilts/vndk/v33
...
拉取 platform/prebuilts/vndk/v33
...
继续lunch继续报错
原因:没拉 platform/prebuilts/vndk/v34
...
拉取 platform/prebuilts/vndk/v34
...
继续lunch继续报错
原因:没拉 toolchain/pgo-profiles
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
In file included from build/make/core/config.mk:1316:
build/make/core/soong_config.mk:10: error: toolchain/pgo-profiles/sampling/afdo_profiles.mk: No such file or directory
12:20:41 dumpvars failed with: exit status 1
拉取 toolchain/pgo-profiles
heyang@MSI:~/aosp/main$ repo sync -c toolchain/pgo-profiles
Fetching: 100% (1/1), done in 1.745s
Updating files: 100% (29/29), done.
Checking out: 100% (1/1), done in 1.820s
repo sync has finished successfully.
继续lunch-成功
至此 可执行 lunch 不带参数的命令可以成功了!!!!!!!!!
heyang@MSI:~/aosp/main$ lunch
You are building on Linux
Warning: Cannot display lunch menu.
Note: You can invoke lunch with an explicit target:
usage: lunch [target]
Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng):
============================================
PLATFORM_VERSION_CODENAME=Baklava
PLATFORM_VERSION=Baklava
TARGET_PRODUCT=aosp_cf_x86_64_phone
TARGET_BUILD_VARIANT=eng
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=silvermont
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=silvermont
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-Ubuntu-24.04.1-LTS
HOST_CROSS_OS=windows
BUILD_ID=MAIN
OUT_DIR=out
============================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wondering whether to use user, userdebug or eng?
user The builds that ship to users. Reduced debugability.
userdebug High fidelity to user builds but with some debugging options
enabled. Best suited for performance testing or day-to-day use
with debugging enabled.
eng More debugging options enabled and faster build times, but
runtime performance tradeoffs. Best suited for day-to-day
local development when not doing performance testing.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
此时out目录:
从38文件增加到41,新增3文件:
target 目录下:
build_fingerprint.txt
build_thumbprint.txt
release-config 目录下:
release_config-aosp_cf_x86_64_phone-trunk_staging.vars
这个文件列出了此产品的所有发布配置的值文件
heyang@MSI:~/aosp/main$ tree out/
out/
├── Android.mk
├── CleanSpec.mk
├── build_date.txt
├── dumpvars-build.trace.1.gz
├── dumpvars-build.trace.gz
├── dumpvars-error.1.log
├── dumpvars-error.log
├── dumpvars-soong.1.log
├── dumpvars-soong.log
├── dumpvars-soong_metrics
├── dumpvars-verbose.log.1.gz
├── dumpvars-verbose.log.gz
├── file_name_tag.txt
├── microfactory_Linux
├── mk2rbc
├── ninja_build
├── rbcrun
├── release-config
├── release-config.out
├── soong
│ ├── build_number.txt
│ └── release-config
│ ├── all_release_configs-.json
│ ├── all_release_configs-.pb
│ ├── all_release_configs-.textproto
│ ├── all_release_configs-aosp_cf_x86_64_phone.json
│ ├── all_release_configs-aosp_cf_x86_64_phone.pb
│ ├── all_release_configs-aosp_cf_x86_64_phone.textproto
│ ├── build_flags_com.android.wifi.json
│ ├── build_flags_host.json
│ ├── build_flags_product.json
│ ├── build_flags_system.json
│ ├── build_flags_system_ext.json
│ ├── build_flags_vendor.json
│ ├── inheritance_graph-.dot
│ ├── inheritance_graph-aosp_cf_x86_64_phone.dot
│ ├── release_config--.varmk
│ ├── release_config--trunk_staging.varmk
│ ├── release_config-aosp_cf_x86_64_phone-trunk_staging.varmk
│ └── release_config-aosp_cf_x86_64_phone-trunk_staging.vars
├── soong_ui
└── target
└── product
└── vsoc_x86_64
├── build_fingerprint.txt
└── build_thumbprint.txt
6 directories, 41 files
list_products 可成功执行:
list_products 命令只会打印产品,不带编译模式:eng等,不带发布配置:trunk_staging 等。
另外至此打印的产品列表很少,可能是我是单个项目拉取的,至此仅是拉取了一个的类型产品集。不带参数的lunch默认参数是:aosp_cf_x86_64_phone-trunk_staging-eng,代表:
aosp项目可以在cult-fish运行的x86_64平台phone类型的带trunk_staging发布配置使用eng构建模式的产品。
可以看出产品列表里的设备只有一种:cf,说明我的设备配置只有一个,查device目录也是如此:
heyang@MSI:~/aosp/main$ list_products
aosp_64bitonly_x86_64
aosp_arm
aosp_arm64
aosp_arm64_fullmte
aosp_cf_arm64_auto
aosp_cf_arm64_minidroid
aosp_cf_arm64_only_phone
aosp_cf_arm64_only_phone_hwasan
aosp_cf_arm64_phone
aosp_cf_arm64_phone_fullmte
aosp_cf_arm64_phone_hwasan
aosp_cf_arm64_phone_pgagnostic
aosp_cf_arm64_slim
aosp_cf_arm_minidroid
aosp_cf_riscv64_minidroid
aosp_cf_riscv64_phone
aosp_cf_riscv64_slim
aosp_cf_riscv64_wear
aosp_cf_x86_64_auto
aosp_cf_x86_64_auto_dd
aosp_cf_x86_64_auto_md
aosp_cf_x86_64_auto_mdnd
aosp_cf_x86_64_auto_portrait
aosp_cf_x86_64_foldable
aosp_cf_x86_64_host
aosp_cf_x86_64_minidroid
aosp_cf_x86_64_only_phone
aosp_cf_x86_64_only_phone_hsum
aosp_cf_x86_64_pc
aosp_cf_x86_64_phone
aosp_cf_x86_64_phone_pgagnostic
aosp_cf_x86_64_phone_soong_system
aosp_cf_x86_64_phone_vendor
aosp_cf_x86_64_slim
aosp_cf_x86_64_ssi
aosp_cf_x86_64_tv
aosp_cf_x86_64_wear
aosp_cf_x86_go_phone
aosp_cf_x86_only_phone
aosp_cf_x86_tv
aosp_cf_x86_wear
aosp_riscv64
aosp_x86
aosp_x86_64
aosp_x86_arm
full
full_x86
generic
generic_system_arm64
generic_system_x86
generic_system_x86_64
generic_system_x86_arm
generic_x86
linux_bionic
mainline_sdk
mainline_system_arm64
mainline_system_x86
mainline_system_x86_64
mainline_system_x86_arm
module_arm
module_arm64
module_arm64only
module_riscv64
module_x86
module_x86_64
module_x86_64only
ndk
sdk
sdk_with_runtime_apis
试试其他lunch目标:
总结
lunch其他目标有部分不成功,主要原因是没该产品的完整配置。
aosp_cf_x86_64_pc 成功
heyang@MSI:~/aosp/main$ lunch aosp_cf_x86_64_pc-trunk_staging-eng
============================================
PLATFORM_VERSION_CODENAME=Baklava
PLATFORM_VERSION=Baklava
TARGET_PRODUCT=aosp_cf_x86_64_pc
TARGET_BUILD_VARIANT=eng
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=silvermont
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-Ubuntu-24.04.1-LTS
HOST_CROSS_OS=windows
BUILD_ID=MAIN
OUT_DIR=out
============================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wondering whether to use user, userdebug or eng?
user The builds that ship to users. Reduced debugability.
userdebug High fidelity to user builds but with some debugging options
enabled. Best suited for performance testing or day-to-day use
with debugging enabled.
eng More debugging options enabled and faster build times, but
runtime performance tradeoffs. Best suited for day-to-day
local development when not doing performance testing.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sdk 成功
heyang@MSI:~/aosp/main$ lunch sdk-trunk_staging-eng
============================================
PLATFORM_VERSION_CODENAME=Baklava
PLATFORM_VERSION=Baklava
TARGET_PRODUCT=sdk
TARGET_BUILD_VARIANT=eng
TARGET_ARCH=x86
TARGET_ARCH_VARIANT=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-Ubuntu-24.04.1-LTS
HOST_CROSS_OS=windows
BUILD_ID=MAIN
OUT_DIR=out
============================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wondering whether to use user, userdebug or eng?
user The builds that ship to users. Reduced debugability.
userdebug High fidelity to user builds but with some debugging options
enabled. Best suited for performance testing or day-to-day use
with debugging enabled.
eng More debugging options enabled and faster build times, but
runtime performance tradeoffs. Best suited for day-to-day
local development when not doing performance testing.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ndk 成功
heyang@MSI:~/aosp/main$ lunch ndk-trunk_staging-eng
============================================
PLATFORM_VERSION_CODENAME=Baklava
PLATFORM_VERSION=Baklava
TARGET_PRODUCT=ndk
TARGET_BUILD_VARIANT=eng
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-Ubuntu-24.04.1-LTS
HOST_CROSS_OS=windows
BUILD_ID=MAIN
OUT_DIR=out
============================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wondering whether to use user, userdebug or eng?
user The builds that ship to users. Reduced debugability.
userdebug High fidelity to user builds but with some debugging options
enabled. Best suited for performance testing or day-to-day use
with debugging enabled.
eng More debugging options enabled and faster build times, but
runtime performance tradeoffs. Best suited for day-to-day
local development when not doing performance testing.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aosp_arm 成功:
heyang@MSI:~/aosp/main$ lunch aosp_arm-trunk_staging-eng
============================================
PLATFORM_VERSION_CODENAME=Baklava
PLATFORM_VERSION=Baklava
TARGET_PRODUCT=aosp_arm
TARGET_BUILD_VARIANT=eng
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=generic
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-Ubuntu-24.04.1-LTS
HOST_CROSS_OS=windows
BUILD_ID=MAIN
OUT_DIR=out
============================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wondering whether to use user, userdebug or eng?
user The builds that ship to users. Reduced debugability.
userdebug High fidelity to user builds but with some debugging options
enabled. Best suited for performance testing or day-to-day use
with debugging enabled.
eng More debugging options enabled and faster build times, but
runtime performance tradeoffs. Best suited for day-to-day
local development when not doing performance testing.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aosp_arm64 成功:
heyang@MSI:~/aosp/main$ lunch aosp_arm64-trunk_staging-eng
============================================
PLATFORM_VERSION_CODENAME=Baklava
PLATFORM_VERSION=Baklava
TARGET_PRODUCT=aosp_arm64
TARGET_BUILD_VARIANT=eng
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=generic
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-Ubuntu-24.04.1-LTS
HOST_CROSS_OS=windows
BUILD_ID=MAIN
OUT_DIR=out
============================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wondering whether to use user, userdebug or eng?
user The builds that ship to users. Reduced debugability.
userdebug High fidelity to user builds but with some debugging options
enabled. Best suited for performance testing or day-to-day use
with debugging enabled.
eng More debugging options enabled and faster build times, but
runtime performance tradeoffs. Best suited for day-to-day
local development when not doing performance testing.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aosp_cf_arm64_phone 失败:
heyang@MSI:~/aosp/main$ rm -rf out/
heyang@MSI:~/aosp/main$ lunch aosp_cf_arm64_phone_x86_64-trunk_staging-eng
In file included from build/make/core/config.mk:406:
In file included from build/make/core/envsetup.mk:351:
build/make/core/product_config.mk:226: error: Cannot locate config makefile for product "aosp_cf_arm64_phone_x86_64".
13:08:02 dumpvars failed with: exit status 1
试试编译:
直接lunch不带参数,然后m,报错如下:
原因:go 依赖模块 go-cmp 没找到
heyang@MSI:~/aosp/main$ m
============================================
PLATFORM_VERSION_CODENAME=Baklava
PLATFORM_VERSION=Baklava
TARGET_PRODUCT=aosp_cf_x86_64_phone
TARGET_BUILD_VARIANT=eng
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=silvermont
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=silvermont
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-Ubuntu-24.04.1-LTS
HOST_CROSS_OS=windows
BUILD_ID=MAIN
OUT_DIR=out
============================================
[100% 1/1] bootstrap blueprint
FAILED: bootstrap blueprint
error: external/golang-protobuf/Android.gen.bp:559:1: "golang-protobuf-internal-order" depends on undefined module "go-cmp". Did you mean ["go2bp"]?
13:16:24 bootstrap failed
#### failed to build some targets (6 seconds) ####
后续
ASOP 豆芽教程《二》- 从m准备blueprint开始-CSDN博客
再下一章,基于当前环境解决编译问题。