summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2025-02-19 13:12:08 -0800
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2025-02-19 13:12:08 -0800
commit435752edcdc4d03db20558b59664e759afa60436 (patch)
treeca3a6bd57b4cd6b92f7c1e2261e4f614fb24b76d
parent14b8145bc8a89881a85497e27f12983361bd3bb9 (diff)
parentabec3ecb0a8e94773a8f1eb795f7720c883d0176 (diff)
Merge changes from topic "dependency_sub_dir" into main
* changes: Propagate owners info in filesystem provider Introduce Soong API ctx.OtherModuleSubDir(m Module)
-rw-r--r--android/base_module_context.go6
-rw-r--r--android/module_context.go3
-rw-r--r--android/packaging.go14
-rw-r--r--filesystem/android_device.go34
-rw-r--r--filesystem/filesystem.go20
5 files changed, 77 insertions, 0 deletions
diff --git a/android/base_module_context.go b/android/base_module_context.go
index cdee96f89..5e05f547a 100644
--- a/android/base_module_context.go
+++ b/android/base_module_context.go
@@ -53,6 +53,9 @@ type BaseModuleContext interface {
// dependencies on the module being visited, it returns the dependency tag used for the current dependency.
OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
+ // OtherModuleSubDir returns the string representing the variations of a module.
+ OtherModuleSubDir(m blueprint.Module) string
+
// OtherModuleExists returns true if a module with the specified name exists, as determined by the NameInterface
// passed to Context.SetNameInterface, or SimpleNameInterface if it was not called.
OtherModuleExists(name string) bool
@@ -284,6 +287,9 @@ func (b *baseModuleContext) OtherModuleErrorf(m blueprint.Module, fmt string, ar
func (b *baseModuleContext) OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag {
return b.bp.OtherModuleDependencyTag(getWrappedModule(m))
}
+func (b *baseModuleContext) OtherModuleSubDir(m blueprint.Module) string {
+ return b.bp.OtherModuleSubDir(getWrappedModule(m))
+}
func (b *baseModuleContext) OtherModuleExists(name string) bool { return b.bp.OtherModuleExists(name) }
func (b *baseModuleContext) OtherModuleDependencyVariantExists(variations []blueprint.Variation, name string) bool {
return b.bp.OtherModuleDependencyVariantExists(variations, name)
diff --git a/android/module_context.go b/android/module_context.go
index f279fd9e5..fb62e6749 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -655,6 +655,7 @@ func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, e
owner: owner,
requiresFullInstall: requiresFullInstall,
fullInstallPath: fullInstallPath,
+ variation: m.ModuleSubDir(),
}
m.packagingSpecs = append(m.packagingSpecs, spec)
return spec
@@ -806,6 +807,7 @@ func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, src
owner: owner,
requiresFullInstall: m.requiresFullInstall(),
fullInstallPath: fullInstallPath,
+ variation: m.ModuleSubDir(),
})
return fullInstallPath
@@ -856,6 +858,7 @@ func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name str
owner: owner,
requiresFullInstall: m.requiresFullInstall(),
fullInstallPath: fullInstallPath,
+ variation: m.ModuleSubDir(),
})
return fullInstallPath
diff --git a/android/packaging.go b/android/packaging.go
index 4e0c74a12..6146f02c9 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -72,6 +72,9 @@ type PackagingSpec struct {
// tools that want to interact with these files outside of the build. You should not use it
// inside of the build. Will be nil if this module doesn't require a "full install".
fullInstallPath InstallPath
+
+ // String representation of the variation of the module where this packaging spec is output of
+ variation string
}
type packagingSpecGob struct {
@@ -86,6 +89,15 @@ type packagingSpecGob struct {
ArchType ArchType
Overrides []string
Owner string
+ Variation string
+}
+
+func (p *PackagingSpec) Owner() string {
+ return p.owner
+}
+
+func (p *PackagingSpec) Variation() string {
+ return p.variation
}
func (p *PackagingSpec) ToGob() *packagingSpecGob {
@@ -101,6 +113,7 @@ func (p *PackagingSpec) ToGob() *packagingSpecGob {
ArchType: p.archType,
Overrides: p.overrides.ToSlice(),
Owner: p.owner,
+ Variation: p.variation,
}
}
@@ -116,6 +129,7 @@ func (p *PackagingSpec) FromGob(data *packagingSpecGob) {
p.archType = data.ArchType
p.overrides = uniquelist.Make(data.Overrides)
p.owner = data.Owner
+ p.variation = data.Variation
}
func (p *PackagingSpec) GobEncode() ([]byte, error) {
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 4f6f9838c..47c4e3d0c 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -15,7 +15,9 @@
package filesystem
import (
+ "cmp"
"fmt"
+ "slices"
"strings"
"sync/atomic"
@@ -247,6 +249,38 @@ func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.distFiles(ctx)
}
+// Returns a list of modules that are installed, which are collected from the dependency
+// filesystem and super_image modules.
+func (a *androidDevice) allInstalledModules(ctx android.ModuleContext) []android.Module {
+ fsInfoMap := a.getFsInfos(ctx)
+ allOwners := make(map[string][]string)
+ for _, partition := range android.SortedKeys(fsInfoMap) {
+ fsInfo := fsInfoMap[partition]
+ for _, owner := range fsInfo.Owners {
+ allOwners[owner.Name] = append(allOwners[owner.Name], owner.Variation)
+ }
+ }
+
+ ret := []android.Module{}
+ ctx.WalkDepsProxy(func(mod, _ android.ModuleProxy) bool {
+ if variations, ok := allOwners[mod.Name()]; ok && android.InList(ctx.OtherModuleSubDir(mod), variations) {
+ ret = append(ret, mod)
+ }
+ return true
+ })
+
+ // Remove duplicates
+ ret = android.FirstUniqueFunc(ret, func(a, b android.Module) bool {
+ return a.String() == b.String()
+ })
+
+ // Sort the modules by their names and variants
+ slices.SortFunc(ret, func(a, b android.Module) int {
+ return cmp.Compare(a.String(), b.String())
+ })
+ return ret
+}
+
func (a *androidDevice) distFiles(ctx android.ModuleContext) {
if !ctx.Config().KatiEnabled() {
if proptools.Bool(a.deviceProps.Main_device) {
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index c0fb636ea..40a460b31 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -384,6 +384,11 @@ type InstalledFilesStruct struct {
Json android.Path
}
+type InstalledModuleInfo struct {
+ Name string
+ Variation string
+}
+
type FilesystemInfo struct {
// The built filesystem image
Output android.Path
@@ -434,6 +439,8 @@ type FilesystemInfo struct {
SelinuxFc android.Path
FilesystemConfig android.Path
+
+ Owners []InstalledModuleInfo
}
// FullInstallPathInfo contains information about the "full install" paths of all the files
@@ -682,6 +689,7 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ErofsCompressHints: erofsCompressHints,
SelinuxFc: f.selinuxFc,
FilesystemConfig: f.generateFilesystemConfig(ctx, rootDir, rebasedDir),
+ Owners: f.gatherOwners(specs),
}
android.SetProvider(ctx, FilesystemProvider, fsInfo)
@@ -1335,6 +1343,18 @@ func (f *filesystem) gatherFilteredPackagingSpecs(ctx android.ModuleContext) map
return f.PackagingBase.GatherPackagingSpecsWithFilterAndModifier(ctx, f.filesystemBuilder.FilterPackagingSpec, f.filesystemBuilder.ModifyPackagingSpec)
}
+func (f *filesystem) gatherOwners(specs map[string]android.PackagingSpec) []InstalledModuleInfo {
+ var owners []InstalledModuleInfo
+ for _, p := range android.SortedKeys(specs) {
+ spec := specs[p]
+ owners = append(owners, InstalledModuleInfo{
+ Name: spec.Owner(),
+ Variation: spec.Variation(),
+ })
+ }
+ return owners
+}
+
// Dexpreopt files are installed to system_other. Collect the packaingSpecs for the dexpreopt files
// from this partition to export to the system_other partition later.
func (f *filesystem) systemOtherFiles(ctx android.ModuleContext) map[string]android.PackagingSpec {