Handle the case where the release value set is a list.
Bug: 304814040
Test: CI, unit test,
b build build/make/tools/aconfig:aconfig.test.cpp
b test build/make/tools/aconfig:AconfigJavaHostTest
Change-Id: I9ca939348a063c39e9528f24e788f9757458d30c
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 5354611..40f7d7f 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -531,6 +531,8 @@
}
Bp2buildModuleAlwaysConvertList = []string{
+ "aconfig.test.cpp",
+ "AconfigJavaHostTest",
// aconfig
"libonce_cell",
"libanyhow",
diff --git a/android/config.go b/android/config.go
index 2930c86..8f72239 100644
--- a/android/config.go
+++ b/android/config.go
@@ -200,21 +200,23 @@
}
// The aconfig value set passed to aconfig, derived from RELEASE_VERSION
-func (c Config) ReleaseAconfigValueSets() string {
+func (c Config) ReleaseAconfigValueSets() []string {
// This logic to handle both Soong module name and bazel target is temporary in order to
// provide backward compatibility where aosp and internal both have the release
// aconfig value set but can't be updated at the same time to use bazel target
- value := strings.Split(c.config.productVariables.ReleaseAconfigValueSets, ":")
- value_len := len(value)
- if value_len > 2 {
- // This shouldn't happen as this should be either a module name or a bazel target path.
- panic(fmt.Errorf("config file: invalid value for release aconfig value sets: %s",
- c.config.productVariables.ReleaseAconfigValueSets))
+ var valueSets []string
+ for _, valueSet := range c.config.productVariables.ReleaseAconfigValueSets {
+ value := strings.Split(valueSet, ":")
+ valueLen := len(value)
+ if valueLen > 2 {
+ // This shouldn't happen as this should be either a module name or a bazel target path.
+ panic(fmt.Errorf("config file: invalid value for release aconfig value sets: %s", valueSet))
+ }
+ if valueLen > 0 {
+ valueSets = append(valueSets, value[valueLen-1])
+ }
}
- if value_len > 0 {
- return value[value_len-1]
- }
- return ""
+ return valueSets
}
// The flag default permission value passed to aconfig
diff --git a/android/variable.go b/android/variable.go
index 006a77f..ab6dfef 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -474,8 +474,8 @@
ProductBrand string `json:",omitempty"`
BuildVersionTags []string `json:",omitempty"`
- ReleaseVersion string `json:",omitempty"`
- ReleaseAconfigValueSets string `json:",omitempty"`
+ ReleaseVersion string `json:",omitempty"`
+ ReleaseAconfigValueSets []string `json:",omitempty"`
ReleaseAconfigFlagDefaultPermission string `json:",omitempty"`