summaryrefslogtreecommitdiff
path: root/android/variable.go
diff options
context:
space:
mode:
author Liz Kammer <eakammer@google.com> 2023-09-20 15:10:18 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2023-09-20 15:10:18 +0000
commit8e9ccda5d8082c642ff74c0cbc5fc48c99ca4ae8 (patch)
treef9204225cae7ffcb5a8d5e161363e664259afc7f /android/variable.go
parent9e12c7863726889853d12d8dea2bf7574b96133e (diff)
parent9e2a5a7d6d311902803997582b67b8dc1495b865 (diff)
Merge "Don't panic for unhandled product vars" into main
Diffstat (limited to 'android/variable.go')
-rw-r--r--android/variable.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/android/variable.go b/android/variable.go
index a495544b8..d33294c16 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -675,7 +675,8 @@ type ProductConfigProperties map[string]map[ProductConfigOrSoongConfigProperty]i
// ProductVariableProperties returns a ProductConfigProperties containing only the properties which
// have been set for the given module.
-func ProductVariableProperties(ctx ArchVariantContext, module Module) ProductConfigProperties {
+func ProductVariableProperties(ctx ArchVariantContext, module Module) (ProductConfigProperties, []error) {
+ var errs []error
moduleBase := module.base()
productConfigProperties := ProductConfigProperties{}
@@ -699,12 +700,15 @@ func ProductVariableProperties(ctx ArchVariantContext, module Module) ProductCon
for namespace, namespacedVariableProps := range m.namespacedVariableProps() {
for _, namespacedVariableProp := range namespacedVariableProps {
variableValues := reflect.ValueOf(namespacedVariableProp).Elem().FieldByName(soongconfig.SoongConfigProperty)
- productConfigProperties.AddSoongConfigProperties(namespace, variableValues)
+ err := productConfigProperties.AddSoongConfigProperties(namespace, variableValues)
+ if err != nil {
+ errs = append(errs, err)
+ }
}
}
}
- return productConfigProperties
+ return productConfigProperties, errs
}
func (p *ProductConfigProperties) AddProductConfigProperty(
@@ -826,7 +830,7 @@ func (productConfigProperties *ProductConfigProperties) AddProductConfigProperti
}
-func (productConfigProperties *ProductConfigProperties) AddSoongConfigProperties(namespace string, soongConfigVariablesStruct reflect.Value) {
+func (productConfigProperties *ProductConfigProperties) AddSoongConfigProperties(namespace string, soongConfigVariablesStruct reflect.Value) error {
//
// Example of soong_config_variables:
//
@@ -923,7 +927,7 @@ func (productConfigProperties *ProductConfigProperties) AddSoongConfigProperties
if propertyName == "Target" {
productConfigProperties.AddSoongConfigPropertiesFromTargetStruct(namespace, variableName, proptools.PropertyNameForField(propertyOrValueName), field.Field(k))
} else if propertyName == "Arch" || propertyName == "Multilib" {
- panic("Arch/Multilib are not currently supported in soong config variable structs")
+ return fmt.Errorf("Arch/Multilib are not currently supported in soong config variable structs")
} else {
productConfigProperties.AddSoongConfigProperty(propertyName, namespace, variableName, proptools.PropertyNameForField(propertyOrValueName), "", field.Field(k).Interface())
}
@@ -934,13 +938,14 @@ func (productConfigProperties *ProductConfigProperties) AddSoongConfigProperties
if propertyOrValueName == "Target" {
productConfigProperties.AddSoongConfigPropertiesFromTargetStruct(namespace, variableName, "", propertyOrStruct)
} else if propertyOrValueName == "Arch" || propertyOrValueName == "Multilib" {
- panic("Arch/Multilib are not currently supported in soong config variable structs")
+ return fmt.Errorf("Arch/Multilib are not currently supported in soong config variable structs")
} else {
productConfigProperties.AddSoongConfigProperty(propertyOrValueName, namespace, variableName, "", "", propertyOrStruct.Interface())
}
}
}
}
+ return nil
}
func (productConfigProperties *ProductConfigProperties) AddSoongConfigPropertiesFromTargetStruct(namespace, soongConfigVariableName string, soongConfigVariableValue string, targetStruct reflect.Value) {