Add prebuilt_visibility property
Some mainline modules provide an `sdk` and one or more set of
module_exports. When the snapshots are unpacked into separate prebuilts
directories (one per snapshot) then any dependencies from a member of
one snapshot to a member of another may require the latter to have
additional visibility rules.
Previously, these rules had to be added to each source module. This
change allows additional visibility rules to be specified on the
sdk/module_exports that are added to all the prebuilts in its snapshot.
Bug: 155921753
Bug: 168301990
Test: m nothing
Change-Id: Ia3eacb5749981f04770ae9872a8013e43c5c6ef1
diff --git a/sdk/update.go b/sdk/update.go
index a10e852..f29b5a0 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -300,7 +300,7 @@
snapshotModule.AddProperty("name", snapshotName)
// Make sure that the snapshot has the same visibility as the sdk.
- visibility := android.EffectiveVisibilityRules(ctx, s)
+ visibility := android.EffectiveVisibilityRules(ctx, s).Strings()
if len(visibility) != 0 {
snapshotModule.AddProperty("visibility", visibility)
}
@@ -719,7 +719,15 @@
} else {
// Extract visibility information from a member variant. All variants have the same
// visibility so it doesn't matter which one is used.
- visibility := android.EffectiveVisibilityRules(s.ctx, variant)
+ visibilityRules := android.EffectiveVisibilityRules(s.ctx, variant)
+
+ // Add any additional visibility rules needed for the prebuilts to reference each other.
+ err := visibilityRules.Widen(s.sdk.properties.Prebuilt_visibility)
+ if err != nil {
+ s.ctx.PropertyErrorf("prebuilt_visibility", "%s", err)
+ }
+
+ visibility := visibilityRules.Strings()
if len(visibility) != 0 {
m.AddProperty("visibility", visibility)
}