Merge "Add ConvertApexAvailableToTags" am: 1d09ec6fca
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2431432 Change-Id: I3a062563717841fe323696bbd31c66a125e63a21 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -709,24 +709,29 @@ func (t *topDownMutatorContext) CreateBazelTargetModuleWithRestrictions(
|
|||||||
// module and returns it as a list of keyed tags.
|
// module and returns it as a list of keyed tags.
|
||||||
func ApexAvailableTags(mod Module) bazel.StringListAttribute {
|
func ApexAvailableTags(mod Module) bazel.StringListAttribute {
|
||||||
attr := bazel.StringListAttribute{}
|
attr := bazel.StringListAttribute{}
|
||||||
tags := []string{}
|
|
||||||
// Transform specific attributes into tags.
|
// Transform specific attributes into tags.
|
||||||
if am, ok := mod.(ApexModule); ok {
|
if am, ok := mod.(ApexModule); ok {
|
||||||
// TODO(b/218841706): hidl_interface has the apex_available prop, but it's
|
// 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
|
// defined directly as a prop and not via ApexModule, so this doesn't
|
||||||
// pick those props up.
|
// pick those props up.
|
||||||
// TODO(b/260694842): This does not pick up aidl_interface.backend.ndk.apex_available.
|
attr.Value = ConvertApexAvailableToTags(am.apexModuleBase().ApexAvailable())
|
||||||
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
|
return attr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ConvertApexAvailableToTags(apexAvailable []string) []string {
|
||||||
|
if len(apexAvailable) == 0 {
|
||||||
|
// We need nil specifically to make bp2build not add the tags property at all,
|
||||||
|
// instead of adding it with an empty list
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
result := make([]string, 0, len(apexAvailable))
|
||||||
|
for _, a := range apexAvailable {
|
||||||
|
result = append(result, "apex_available="+a)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func (t *topDownMutatorContext) createBazelTargetModule(
|
func (t *topDownMutatorContext) createBazelTargetModule(
|
||||||
bazelProps bazel.BazelTargetModuleProperties,
|
bazelProps bazel.BazelTargetModuleProperties,
|
||||||
commonAttrs CommonAttributes,
|
commonAttrs CommonAttributes,
|
||||||
|
@@ -16,6 +16,7 @@ package android
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -267,3 +268,22 @@ func TestNoCreateVariationsInFinalDeps(t *testing.T) {
|
|||||||
FixtureWithRootAndroidBp(`test {name: "foo"}`),
|
FixtureWithRootAndroidBp(`test {name: "foo"}`),
|
||||||
).RunTest(t)
|
).RunTest(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConvertApexAvailableToTags(t *testing.T) {
|
||||||
|
input := []string{
|
||||||
|
"com.android.adbd",
|
||||||
|
"//apex_available:platform",
|
||||||
|
}
|
||||||
|
actual := ConvertApexAvailableToTags(input)
|
||||||
|
expected := []string{
|
||||||
|
"apex_available=com.android.adbd",
|
||||||
|
"apex_available=//apex_available:platform",
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(actual, expected) {
|
||||||
|
t.Errorf("Expected: %v, actual: %v", expected, actual)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ConvertApexAvailableToTags(nil) != nil {
|
||||||
|
t.Errorf("Expected providing nil to return nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user