Revert ^2 "Prevent unspecified values in soong_config_string_variable""

This reverts commit 38944c70c4.

Reason for revert: I believe we're ready for this now, but run build_test 1-4 on internal master for at least master and tm-dev-plus-aosp on go/abtd before submitting

Change-Id: Id3bcd9a46f3087cf2d34dece5294828ea9436788
This commit is contained in:
Cole Faust
2022-10-20 00:34:00 +00:00
parent 38944c70c4
commit 135d987d7c
2 changed files with 64 additions and 1 deletions

View File

@@ -639,9 +639,13 @@ func (s *stringVariable) initializeProperties(v reflect.Value, typ reflect.Type)
// Extracts an interface from values containing the properties to apply based on config.
// If config does not match a value with a non-nil property set, the default value will be returned.
func (s *stringVariable) PropertiesToApply(config SoongConfig, values reflect.Value) (interface{}, error) {
configValue := config.String(s.variable)
if configValue != "" && !InList(configValue, s.values) {
return nil, fmt.Errorf("Soong config property %q must be one of %v, found %q", s.variable, s.values, configValue)
}
for j, v := range s.values {
f := values.Field(j)
if config.String(s.variable) == v && !f.Elem().IsNil() {
if configValue == v && !f.Elem().IsNil() {
return f.Interface(), nil
}
}
@@ -858,3 +862,13 @@ type emptyInterfaceStruct struct {
}
var emptyInterfaceType = reflect.TypeOf(emptyInterfaceStruct{}).Field(0).Type
// InList checks if the string belongs to the list
func InList(s string, list []string) bool {
for _, s2 := range list {
if s2 == s {
return true
}
}
return false
}