Merge "Convert apex_available (for supported modules) to bazel tags."

This commit is contained in:
Jingwen Chen
2022-12-02 07:22:10 +00:00
committed by Gerrit Code Review
8 changed files with 134 additions and 34 deletions

View File

@@ -705,6 +705,28 @@ func (t *topDownMutatorContext) CreateBazelTargetModuleWithRestrictions(
t.createBazelTargetModule(bazelProps, commonAttrs, attrs, enabledProperty)
}
// ApexAvailableTags converts the apex_available property value of an ApexModule
// module and returns it as a list of keyed tags.
func ApexAvailableTags(mod Module) bazel.StringListAttribute {
attr := bazel.StringListAttribute{}
tags := []string{}
// Transform specific attributes into tags.
if am, ok := mod.(ApexModule); ok {
// TODO(b/218841706): hidl_interface has the apex_available prop, but it's
// defined directly as a prop and not via ApexModule, so this doesn't
// pick those props up.
// TODO(b/260694842): This does not pick up aidl_interface.backend.ndk.apex_available.
for _, a := range am.apexModuleBase().ApexAvailable() {
tags = append(tags, "apex_available="+a)
}
}
if len(tags) > 0 {
// This avoids creating a tags attr with an empty list if there are no tags.
attr.Value = tags
}
return attr
}
func (t *topDownMutatorContext) createBazelTargetModule(
bazelProps bazel.BazelTargetModuleProperties,
commonAttrs CommonAttributes,