Add test & documentation for PropertiesToApply

Document PropertiesToApply expectations about props, and suggest it
should generally be generated via CreateProperties.

Test: go soong tests
Test: m nothing
Change-Id: I7cc2590db96865382ad6e0da333d4a4e2c697f45
This commit is contained in:
Liz Kammer
2020-12-16 09:34:33 -08:00
parent 61f6eb6664
commit fe8853d2e6
2 changed files with 83 additions and 5 deletions

View File

@@ -158,11 +158,7 @@ func processModuleTypeDef(v *SoongConfigDefinition, def *parser.Module) (errs []
return []error{fmt.Errorf("bool_variable name must not be blank")}
}
mt.Variables = append(mt.Variables, &boolVariable{
baseVariable: baseVariable{
variable: name,
},
})
mt.Variables = append(mt.Variables, newBoolVariable(name))
}
for _, name := range props.Value_variables {
@@ -420,6 +416,9 @@ func typeForPropertyFromPropertyStruct(ps interface{}, property string) reflect.
// PropertiesToApply returns the applicable properties from a ModuleType that should be applied
// based on SoongConfig values.
// Expects that props contains a struct field with name soong_config_variables. The fields within
// soong_config_variables are expected to be in the same order as moduleType.Variables. In general,
// props should be generated via CreateProperties.
func PropertiesToApply(moduleType *ModuleType, props reflect.Value, config SoongConfig) ([]interface{}, error) {
var ret []interface{}
props = props.Elem().FieldByName(soongConfigProperty)
@@ -505,6 +504,14 @@ type boolVariable struct {
baseVariable
}
func newBoolVariable(name string) *boolVariable {
return &boolVariable{
baseVariable{
variable: name,
},
}
}
func (b boolVariable) variableValuesType() reflect.Type {
return emptyInterfaceType
}