Propagate installed files of Include_files_of dependencies
Some partitions (e.g. recovery) are transitive dependencies of
android_device module, and are not directly listed as partitions. This
change allows the installed files of `Include_files_of` partitions to be
propagated to the rdep filesystem module, so that it can reach the
android_device module and be disted.
Test: m nothing dist --soong-only && aninja -t query _dist_droidcore-unbundled
Bug: 395162005
Change-Id: Icc0e902d5d42b925d04470b60b5e62daac4c4a17
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 86771d1..a26ed43 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -319,22 +319,32 @@
return strings.TrimSuffix(file, ext) + insertion + ext
}
+func (a *androidDevice) distInstalledFiles(ctx android.ModuleContext) {
+ distInstalledFilesJsonAndTxt := func(installedFiles InstalledFilesStruct) {
+ if installedFiles.Json != nil {
+ ctx.DistForGoal("droidcore-unbundled", installedFiles.Json)
+ }
+ if installedFiles.Txt != nil {
+ ctx.DistForGoal("droidcore-unbundled", installedFiles.Txt)
+ }
+ }
+
+ fsInfoMap := a.getFsInfos(ctx)
+ for _, partition := range android.SortedKeys(fsInfoMap) {
+ // installed-files-*{.txt | .json} is not disted for userdata partition
+ if partition == "userdata" {
+ continue
+ }
+ fsInfo := fsInfoMap[partition]
+ for _, installedFiles := range fsInfo.InstalledFilesDepSet.ToList() {
+ distInstalledFilesJsonAndTxt(installedFiles)
+ }
+ }
+}
+
func (a *androidDevice) distFiles(ctx android.ModuleContext) {
if !ctx.Config().KatiEnabled() && proptools.Bool(a.deviceProps.Main_device) {
- fsInfoMap := a.getFsInfos(ctx)
- for _, partition := range android.SortedKeys(fsInfoMap) {
- // installed-files-*{.txt | .json} is not disted for userdata partition
- if partition == "userdata" {
- continue
- }
- fsInfo := fsInfoMap[partition]
- if fsInfo.InstalledFiles.Json != nil {
- ctx.DistForGoal("droidcore-unbundled", fsInfo.InstalledFiles.Json)
- }
- if fsInfo.InstalledFiles.Txt != nil {
- ctx.DistForGoal("droidcore-unbundled", fsInfo.InstalledFiles.Txt)
- }
- }
+ a.distInstalledFiles(ctx)
namePrefix := ""
if ctx.Config().HasDeviceProduct() {
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 6eada58..0cd5fb4 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -30,6 +30,7 @@
"android/soong/linkerconfig"
"github.com/google/blueprint"
+ "github.com/google/blueprint/depset"
"github.com/google/blueprint/proptools"
)
@@ -424,8 +425,8 @@
FullInstallPaths []FullInstallPathInfo
- // Installed files list
- InstalledFiles InstalledFilesStruct
+ // Installed files dep set of this module and its dependency filesystem modules
+ InstalledFilesDepSet depset.DepSet[InstalledFilesStruct]
// Path to compress hints file for erofs filesystems
// This will be nil for other fileystems like ext4
@@ -543,13 +544,13 @@
}
}
-func buildInstalledFiles(ctx android.ModuleContext, partition string, rootDir android.Path, image android.Path) (txt android.ModuleOutPath, json android.ModuleOutPath) {
+func buildInstalledFiles(ctx android.ModuleContext, partition string, rootDir android.Path, image android.Path) InstalledFilesStruct {
fileName := "installed-files"
if len(partition) > 0 {
fileName += fmt.Sprintf("-%s", partition)
}
- txt = android.PathForModuleOut(ctx, fmt.Sprintf("%s.txt", fileName))
- json = android.PathForModuleOut(ctx, fmt.Sprintf("%s.json", fileName))
+ txt := android.PathForModuleOut(ctx, fmt.Sprintf("%s.txt", fileName))
+ json := android.PathForModuleOut(ctx, fmt.Sprintf("%s.json", fileName))
ctx.Build(pctx, android.BuildParams{
Rule: installedFilesJsonRule,
@@ -568,7 +569,10 @@
Description: "Installed file list txt",
})
- return txt, json
+ return InstalledFilesStruct{
+ Txt: txt,
+ Json: json,
+ }
}
func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -660,7 +664,6 @@
default:
partitionNameForInstalledFiles = f.partitionName()
}
- installedFileTxt, installedFileJson := buildInstalledFiles(ctx, partitionNameForInstalledFiles, rootDir, f.output)
var erofsCompressHints android.Path
if f.properties.Erofs.Compress_hints != nil {
@@ -681,10 +684,11 @@
BuildImagePropFileDeps: buildImagePropFileDeps,
SpecsForSystemOther: f.systemOtherFiles(ctx),
FullInstallPaths: fullInstallPaths,
- InstalledFiles: InstalledFilesStruct{
- Txt: installedFileTxt,
- Json: installedFileJson,
- },
+ InstalledFilesDepSet: depset.New(
+ depset.POSTORDER,
+ []InstalledFilesStruct{buildInstalledFiles(ctx, partitionNameForInstalledFiles, rootDir, f.output)},
+ includeFilesInstalledFiles(ctx),
+ ),
ErofsCompressHints: erofsCompressHints,
SelinuxFc: f.selinuxFc,
FilesystemConfig: f.generateFilesystemConfig(ctx, rootDir, rebasedDir),
@@ -1175,6 +1179,15 @@
return rootDirs, partitions
}
+func includeFilesInstalledFiles(ctx android.ModuleContext) (ret []depset.DepSet[InstalledFilesStruct]) {
+ ctx.VisitDirectDepsWithTag(interPartitionInstallDependencyTag, func(m android.Module) {
+ if fsProvider, ok := android.OtherModuleProvider(ctx, m, FilesystemProvider); ok {
+ ret = append(ret, fsProvider.InstalledFilesDepSet)
+ }
+ })
+ return
+}
+
func (f *filesystem) buildCpioImage(
ctx android.ModuleContext,
builder *android.RuleBuilder,