背景:
针对上一篇文章给大家步骤的关于aosp15版本上system.img的打包已经和以前aosp14不一样的问题,这里再简单描述如下:
但是在aosp15后,明显发现并不会打包整个system文件夹。
下面来探索这个到底是为啥?
线索追踪:
这里主要通过对比在out目录下对应的img的输出的中间目录
先看aosp14上同样的目录如下:
test@test:~/disk2/aosp14/out/target/product/emulator_x86_64/obj/PACKAGING/systemimage_intermediates$ ls -l
total 991824
-rw-rw-r-- 1 test test 2960 Apr 24 12:36 system_image_info.txt
-rw-rw-r-- 1 test test 1083002880 Apr 24 12:36 system.img
再看aosp15的情况如下:
test@test:~/aosp15/out/target/product/emu64x/obj/PACKAGING/system_intermediates$ ll
total 791680
drwxrwxr-x 2 test test 4096 Apr 24 22:34 ./
drwxrwxr-x 25 test test 4096 Apr 24 11:14 ../
-rw-rw-r-- 1 test test 62288 Apr 24 11:29 file_list.txt
-rw-rw-r-- 1 test test 258910 Apr 24 11:14 file_list.txt.rsp
-rw-rw-r-- 1 test test 992 Apr 24 22:33 system_image_info.txt
-rw-rw-r-- 1 test test 877621248 Apr 24 22:35 system.img
明显多了了个文件file_list.txt和file_list.txt.rsp,这里其实主要就是看file_list.txt文件既可以,可以看看它的内容
不过在文件查找发现并没有我们新编译的目标没有加入PRODUCT_PACKAGES的文件,所以基本上我们就可以断定,aosp15相比aosp14就是在打包img时候,多了这个file_list.txt文件作为过滤依据,在打包img文件时候就是只会打包只有在file_list.txt文件中的,不在文件中也就不会打包。
至于是否使我们猜想的结论可以还需要更多验证,和需要相关build模块的git log来验证,看看这个修改的目的。
追查为什么要加入file_list.txt
这里可以通过在aosp15的代码中进行相关的grep file_list字符,因为涉及是编译模式变化,当然要到build目录进行grep,结果如下:
然后通过git blame看看这个提交记,然后git show看看相关提交详情
test@test:~/aosp15/build/make/core$ git show 152cdfab7c2
commit 152cdfab7c2a02a64b24a706566183d863db7a38
Author: Cole Faust <colefaust@google.com>
Date: Wed Jul 26 14:33:51 2023 -0700
Clean staging dirs in build_image.py
build_image.py now accepts a --input-directory-filter-file argument
that contains a list of files to consider from the input directory.
A new, temporary input directory will be created, and only the
considered files will be copied to it.
This removes most of the need for `m installclean`, as old files or
files built manually will no longer end up on the partition.
Bug: 205632228
Test: Presubmits
Change-Id: I07e0bf8e840abf0b51a2fdf67b758905fb3c5b5b
diff --git a/Changes.md b/Changes.md
index 6836528762..2616117d7a 100644
--- a/Changes.md
+++ b/Changes.md
@@ -1,4 +1,15 @@
-# Build System Changes for Android.mk Writers
+# Build System Changes for Android.mk/Android.bp Writers
+
+## Partitions are no longer affected by previous builds
+
+Partition builds used to include everything in their staging directories, and building an
+individual module will install it to the staging directory. Thus, previously, `m mymodule` followed
+by `m` would cause `mymodule` to be presinstalled on the device, even if it wasn't listed in
+`PRODUCT_PACKAGES`.
+
+This behavior has been changed, and now the partition images only include what they'd have if you
+did a clean build. This behavior can be disabled by setting the
+`BUILD_BROKEN_INCORRECT_PARTITION_IMAGES` environment variable or board config variable.
## Perform validation of Soong plugins
这里大概提交中可以看出:
build_image.py脚本新增的–input-directory-filter-file参数实现了输入目录文件过滤功能,其核心作用与实现逻辑可归纳为
a.通过指定包含文件列表的过滤文件,脚本会自动创建临时输入目录,仅复制列表中明确指定的文件到新目录
b.有效解决了旧版本构建残留文件或手动生成文件意外混入分区的问题
c.通过前置过滤机制保障输入目录纯净度
修改方案:
这里修改方案可以如下两种:
1、正常把目标放入到PRODUCT_PACKAGES,这种就啥事情也没有,本身目标也是系统img的一员
2、不想放入到PRODUCT_PACKAGES,还是想要可以打包到img
这种临时修改方案可以如下:
步骤一:修改out目录下的的file_list文件
修改 out/target/product/emu64x/obj/PACKAGING/system_intermediates/file_list.txt文件,如下
然后再老方法,触发系统重新打包编译,运行模拟器看看现象如下:
更多framework实战vip独享干货,请关注下面“千里马学框架”