Convert apex_available (for supported modules) to bazel tags.
The tags will then be read by an aspect applied from apex attributes to
validate that the deps are explicitly opt-in to the appropriate apex.
The semantics of this is the same as the Soong apex_available property.
This also adds the "base_apex_name" attr to override_apex conversion so
that apex_available checks continue to work on the non-Google and non-Go
apex names.
Test: presubmits
Fixes: 218841706
Change-Id: I19b3637da9aa47573b252d74f62b601fbdc3784d
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 1842e5a..2730052 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -388,7 +388,9 @@
if fullBuild {
name += "_bp2build_cc_library_static"
}
- ctx.CreateBazelTargetModuleWithRestrictions(props, android.CommonAttributes{Name: name}, attrs, prebuiltAttrs.Enabled)
+
+ tags := android.ApexAvailableTags(module)
+ ctx.CreateBazelTargetModuleWithRestrictions(props, android.CommonAttributes{Name: name, Tags: tags}, attrs, prebuiltAttrs.Enabled)
}
type bazelPrebuiltLibrarySharedAttributes struct {
@@ -408,7 +410,8 @@
}
name := android.RemoveOptionalPrebuiltPrefix(module.Name())
- ctx.CreateBazelTargetModuleWithRestrictions(props, android.CommonAttributes{Name: name}, attrs, prebuiltAttrs.Enabled)
+ tags := android.ApexAvailableTags(module)
+ ctx.CreateBazelTargetModuleWithRestrictions(props, android.CommonAttributes{Name: name, Tags: tags}, attrs, prebuiltAttrs.Enabled)
}
type prebuiltObjectProperties struct {
@@ -740,7 +743,8 @@
}
name := android.RemoveOptionalPrebuiltPrefix(module.Name())
- ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
+ tags := android.ApexAvailableTags(module)
+ ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name, Tags: tags}, attrs)
}
type Sanitized struct {