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
This commit is contained in:
Yu Liu
2023-10-12 20:31:27 -07:00
parent 7c81b2b245
commit eebb259356
5 changed files with 59 additions and 17 deletions

View File

@@ -200,21 +200,23 @@ func (c Config) ReleaseVersion() string {
}
// 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