Replace extendProperties with pathtools.AppendProperties
Blueprint has a generic AppendProperties/AppendMatchingProperties now,
use it, and replace all bool properties that might be modified by a
mutator with *bool, which provides the correct replace-if-set semantics
for append.
Also remove uses of ContainsProperty except when explicitly checking if
a property was set in a blueprints file.
Change-Id: If523af61d6b4630e79504d7fc2840f36e98571cc
diff --git a/common/variable.go b/common/variable.go
index 23a97a6..3949681 100644
--- a/common/variable.go
+++ b/common/variable.go
@@ -113,7 +113,7 @@
// TODO: depend on config variable, create variants, propagate variants up tree
a := module.base()
- variableValues := reflect.ValueOf(a.variableProperties.Product_variables)
+ variableValues := reflect.ValueOf(&a.variableProperties.Product_variables).Elem()
zeroValues := reflect.ValueOf(zeroProductVariables.Product_variables)
for i := 0; i < variableValues.NumField(); i++ {
@@ -147,16 +147,19 @@
func (a *AndroidModuleBase) setVariableProperties(ctx blueprint.EarlyMutatorContext,
prefix string, productVariablePropertyValue reflect.Value, variableValue interface{}) {
- generalPropertyValues := make([]reflect.Value, len(a.generalProperties))
- for i := range a.generalProperties {
- generalPropertyValues[i] = reflect.ValueOf(a.generalProperties[i]).Elem()
- }
-
if variableValue != nil {
printfIntoProperties(productVariablePropertyValue, variableValue)
}
- extendProperties(ctx, "", prefix, generalPropertyValues, productVariablePropertyValue, nil)
+ err := proptools.AppendMatchingProperties(a.generalProperties,
+ productVariablePropertyValue.Addr().Interface(), nil)
+ if err != nil {
+ if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
+ ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
+ } else {
+ panic(err)
+ }
+ }
}
func printfIntoProperties(productVariablePropertyValue reflect.Value, variableValue interface{}) {