From 8e6386e0aaaf52097129d12a144ebde52c319a6e Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Tue, 11 Apr 2023 19:08:18 +0000 Subject: [PATCH 1/2] Make //apex_available:platform the default. go/Android.bp mentions that ["//apex_available:platform"] is the default, but currently it was []. This change does not create any additional module variants. (Noticed this for libz, I was expecting its apex_available to be platform and not an empty list) Test: TH Change-Id: I9af06f813b1a1d7b716939874f469bd2e1ce4d14 --- android/apex.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/android/apex.go b/android/apex.go index 87bff74c3..5bbc02e51 100644 --- a/android/apex.go +++ b/android/apex.go @@ -356,9 +356,18 @@ func (m *ApexModuleBase) apexModuleBase() *ApexModuleBase { return m } +var ( + availableToPlatformList = []string{AvailableToPlatform} +) + // Implements ApexModule func (m *ApexModuleBase) ApexAvailable() []string { - return m.ApexProperties.Apex_available + aa := m.ApexProperties.Apex_available + if len(aa) > 0 { + return aa + } + // Default is availability to platform + return CopyOf(availableToPlatformList) } // Implements ApexModule From 2dc6dfcb16e5cb25a1a52f9a96e80a51947b3978 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Mon, 17 Apr 2023 19:16:06 +0000 Subject: [PATCH 2/2] Drop the default apex_available value from BUILD files If apex_available is missing from Android.bp files, ApexAvailable returns [//apex_available:platform], which is the default. To avoid BUILD file verbosity, remove the build system default value from the generated BUILD files. Bug: 277651159 Test: go test ./bp2build Change-Id: I4129c2a93ac28578f46ebeed49baa23ce727aa1f --- android/mutator.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/android/mutator.go b/android/mutator.go index 676f8a511..4ec960472 100644 --- a/android/mutator.go +++ b/android/mutator.go @@ -747,7 +747,13 @@ func ApexAvailableTags(mod Module) bazel.StringListAttribute { // 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. - attr.Value = ConvertApexAvailableToTags(am.apexModuleBase().ApexAvailable()) + apexAvailable := am.apexModuleBase().ApexAvailable() + // If a user does not specify apex_available in Android.bp, then soong provides a default. + // To avoid verbosity of BUILD files, remove this default from user-facing BUILD files. + if len(am.apexModuleBase().ApexProperties.Apex_available) == 0 { + apexAvailable = []string{} + } + attr.Value = ConvertApexAvailableToTags(apexAvailable) } return attr }