summaryrefslogtreecommitdiff
path: root/filesystem/filesystem.go
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-12-03 00:45:58 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-12-03 00:45:58 +0000
commit96d076e26288224a3758db1a4f49eb3f83f48b7c (patch)
tree80c30eff6c286e04490131c0ffec94fe8e306651 /filesystem/filesystem.go
parent5c7d97924127d192fa6bf3e094da687909d14d6f (diff)
parent71be42d93951aaaf95ba520281a9837f32bd738c (diff)
Merge "Automatically add system and system_ext autogen RRO to vendor/product" into main
Diffstat (limited to 'filesystem/filesystem.go')
-rw-r--r--filesystem/filesystem.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 5b217aeec..eb3418064 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -25,6 +25,7 @@ import (
"android/soong/android"
"android/soong/cc"
+ "android/soong/java"
"android/soong/linkerconfig"
"github.com/google/blueprint"
@@ -33,6 +34,7 @@ import (
func init() {
registerBuildComponents(android.InitRegistrationContext)
+ registerMutators(android.InitRegistrationContext)
}
func registerBuildComponents(ctx android.RegistrationContext) {
@@ -45,6 +47,12 @@ func registerBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("avb_gen_vbmeta_image_defaults", avbGenVbmetaImageDefaultsFactory)
}
+func registerMutators(ctx android.RegistrationContext) {
+ ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
+ ctx.BottomUp("add_autogenerated_rro_deps", addAutogeneratedRroDeps)
+ })
+}
+
type filesystem struct {
android.ModuleBase
android.PackagingBase
@@ -170,6 +178,14 @@ type FilesystemProperties struct {
// Path to the dev nodes description file. This is only needed for building the ramdisk
// partition and should not be explicitly specified.
Dev_nodes_description_file *string `android:"path" blueprint:"mutated"`
+
+ // Additional dependencies used for building android products
+ Android_filesystem_deps AndroidFilesystemDeps
+}
+
+type AndroidFilesystemDeps struct {
+ System *string
+ System_ext *string
}
// Additional properties required to generate erofs FS partitions.
@@ -235,6 +251,12 @@ type depTagWithVisibilityEnforcementBypass struct {
depTag
}
+type interPartitionDepTag struct {
+ blueprint.BaseDependencyTag
+}
+
+var interPartitionDependencyTag = interPartitionDepTag{}
+
var _ android.ExcludeFromVisibilityEnforcementTag = (*depTagWithVisibilityEnforcementBypass)(nil)
func (t depTagWithVisibilityEnforcementBypass) ExcludeFromVisibilityEnforcement() {}
@@ -257,6 +279,12 @@ func (f *filesystem) DepsMutator(ctx android.BottomUpMutatorContext) {
} else {
f.AddDeps(ctx, dependencyTag)
}
+ if f.properties.Android_filesystem_deps.System != nil {
+ ctx.AddDependency(ctx.Module(), interPartitionDependencyTag, proptools.String(f.properties.Android_filesystem_deps.System))
+ }
+ if f.properties.Android_filesystem_deps.System_ext != nil {
+ ctx.AddDependency(ctx.Module(), interPartitionDependencyTag, proptools.String(f.properties.Android_filesystem_deps.System_ext))
+ }
}
type fsType int
@@ -1004,3 +1032,30 @@ func assertMaxImageSize(builder *android.RuleBuilder, image android.Path, maxSiz
image, maxSize)
cmd.Implicit(image)
}
+
+// addAutogeneratedRroDeps walks the transitive closure of vendor and product partitions.
+// It visits apps installed in system and system_ext partitions, and adds the autogenerated
+// RRO modules to its own deps.
+func addAutogeneratedRroDeps(ctx android.BottomUpMutatorContext) {
+ f, ok := ctx.Module().(*filesystem)
+ if !ok {
+ return
+ }
+ thisPartition := f.PartitionType()
+ if thisPartition != "vendor" && thisPartition != "product" {
+ return
+ }
+ ctx.WalkDeps(func(child, parent android.Module) bool {
+ depTag := ctx.OtherModuleDependencyTag(child)
+ if parent.Name() == f.Name() && depTag != interPartitionDependencyTag {
+ return false // This is a module listed in deps of vendor/product filesystem
+ }
+ if vendorOverlay := java.AutogeneratedRroModuleName(ctx, child.Name(), "vendor"); ctx.OtherModuleExists(vendorOverlay) && thisPartition == "vendor" {
+ ctx.AddFarVariationDependencies(nil, dependencyTagWithVisibilityEnforcementBypass, vendorOverlay)
+ }
+ if productOverlay := java.AutogeneratedRroModuleName(ctx, child.Name(), "product"); ctx.OtherModuleExists(productOverlay) && thisPartition == "product" {
+ ctx.AddFarVariationDependencies(nil, dependencyTagWithVisibilityEnforcementBypass, productOverlay)
+ }
+ return true
+ })
+}