summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2024-05-22 23:58:50 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-05-22 23:58:50 +0000
commitc15b0234e982f7d76d72180781799c73057f74ea (patch)
treee6015cea5653960d9f70ee7c15d60a486b851917
parent5458a8437de2aa11193a402ff71e77ad0ab31563 (diff)
parent5f297068431ab79d90e474c12d434f1776265a85 (diff)
Merge "Support soong config value variables on Configurable properties" into main
-rw-r--r--android/selects_test.go35
-rw-r--r--android/soongconfig/modules.go15
2 files changed, 45 insertions, 5 deletions
diff --git a/android/selects_test.go b/android/selects_test.go
index 87ba42a94..8089fbc5c 100644
--- a/android/selects_test.go
+++ b/android/selects_test.go
@@ -729,6 +729,38 @@ func TestSelects(t *testing.T) {
},
},
},
+ {
+ name: "Soong config value variable on configurable property",
+ bp: `
+ soong_config_module_type {
+ name: "soong_config_my_module_type",
+ module_type: "my_module_type",
+ config_namespace: "my_namespace",
+ value_variables: ["my_variable"],
+ properties: ["my_string", "my_string_list"],
+ }
+
+ soong_config_my_module_type {
+ name: "foo",
+ my_string_list: ["before.cpp"],
+ soong_config_variables: {
+ my_variable: {
+ my_string_list: ["after_%s.cpp"],
+ my_string: "%s.cpp",
+ },
+ },
+ }
+ `,
+ provider: selectsTestProvider{
+ my_string: proptools.StringPtr("foo.cpp"),
+ my_string_list: &[]string{"before.cpp", "after_foo.cpp"},
+ },
+ vendorVars: map[string]map[string]string{
+ "my_namespace": {
+ "my_variable": "foo",
+ },
+ },
+ },
}
for _, tc := range testCases {
@@ -736,6 +768,7 @@ func TestSelects(t *testing.T) {
fixtures := GroupFixturePreparers(
PrepareForTestWithDefaults,
PrepareForTestWithArchMutator,
+ PrepareForTestWithSoongConfigModuleBuildComponents,
FixtureRegisterWithContext(func(ctx RegistrationContext) {
ctx.RegisterModuleType("my_module_type", newSelectsMockModule)
ctx.RegisterModuleType("my_defaults", newSelectsMockModuleDefaults)
@@ -790,7 +823,7 @@ func (p *selectsTestProvider) String() string {
myStringStr = *p.my_string
}
myNonconfigurableStringStr := "nil"
- if p.my_string != nil {
+ if p.my_nonconfigurable_string != nil {
myNonconfigurableStringStr = *p.my_nonconfigurable_string
}
return fmt.Sprintf(`selectsTestProvider {
diff --git a/android/soongconfig/modules.go b/android/soongconfig/modules.go
index c910974f6..87af774fd 100644
--- a/android/soongconfig/modules.go
+++ b/android/soongconfig/modules.go
@@ -733,11 +733,18 @@ func (s *valueVariable) printfIntoPropertyRecursive(fieldName []string, propStru
case reflect.Bool:
// Nothing to do
case reflect.Struct:
- fieldName = append(fieldName, propStruct.Type().Field(i).Name)
- if err := s.printfIntoPropertyRecursive(fieldName, field, configValue); err != nil {
- return err
+ if proptools.IsConfigurable(field.Type()) {
+ if err := proptools.PrintfIntoConfigurable(field.Interface(), configValue); err != nil {
+ fieldName = append(fieldName, propStruct.Type().Field(i).Name)
+ return fmt.Errorf("soong_config_variables.%s.%s: %s", s.variable, strings.Join(fieldName, "."), err)
+ }
+ } else {
+ fieldName = append(fieldName, propStruct.Type().Field(i).Name)
+ if err := s.printfIntoPropertyRecursive(fieldName, field, configValue); err != nil {
+ return err
+ }
+ fieldName = fieldName[:len(fieldName)-1]
}
- fieldName = fieldName[:len(fieldName)-1]
default:
fieldName = append(fieldName, propStruct.Type().Field(i).Name)
return fmt.Errorf("soong_config_variables.%s.%s: unsupported property type %q", s.variable, strings.Join(fieldName, "."), kind)