Add pointer and bool support for product variables
Change-Id: I90c07878f3c23a6bab1530daa1a80ae1685ab154
diff --git a/common/variable.go b/common/variable.go
index 4f159c5..fa40661 100644
--- a/common/variable.go
+++ b/common/variable.go
@@ -163,9 +163,7 @@
func (a *AndroidModuleBase) setVariableProperties(ctx AndroidBottomUpMutatorContext,
prefix string, productVariablePropertyValue reflect.Value, variableValue interface{}) {
- if variableValue != nil {
- printfIntoProperties(productVariablePropertyValue, variableValue)
- }
+ printfIntoProperties(productVariablePropertyValue, variableValue)
err := proptools.AppendMatchingProperties(a.generalProperties,
productVariablePropertyValue.Addr().Interface(), nil)
@@ -181,6 +179,13 @@
func printfIntoProperties(productVariablePropertyValue reflect.Value, variableValue interface{}) {
for i := 0; i < productVariablePropertyValue.NumField(); i++ {
propertyValue := productVariablePropertyValue.Field(i)
+ kind := propertyValue.Kind()
+ if kind == reflect.Ptr {
+ if propertyValue.IsNil() {
+ continue
+ }
+ propertyValue = propertyValue.Elem()
+ }
switch propertyValue.Kind() {
case reflect.String:
printfIntoProperty(propertyValue, variableValue)
@@ -188,6 +193,8 @@
for j := 0; j < propertyValue.Len(); j++ {
printfIntoProperty(propertyValue.Index(j), variableValue)
}
+ case reflect.Bool:
+ // Nothing
case reflect.Struct:
printfIntoProperties(propertyValue, variableValue)
default: