aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Shields <simon@lineageos.org>2017-09-04 21:09:10 +1000
committerRashed Abdel-Tawab <rashed@linux.com>2019-09-07 14:54:29 -0700
commit0627d813700af4043d6f213d451f9d0fabdbed1c (patch)
tree180ead9657ddebea99cbc974f766ab9e85a7d59e
parent2c1d7ea5e452c323e63c848baf4e5ad77bc77f7c (diff)
downloadbuild_soong-0627d813700af4043d6f213d451f9d0fabdbed1c.tar.gz
build_soong-0627d813700af4043d6f213d451f9d0fabdbed1c.tar.bz2
build_soong-0627d813700af4043d6f213d451f9d0fabdbed1c.zip
soong: add support for nested structs in variableProperties
Change-Id: I0e5395ac70220f1d3a1c87c6112e33f84f526fea
-rw-r--r--android/variable.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/android/variable.go b/android/variable.go
index a30a423e..e169fea5 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -354,7 +354,14 @@ func variableMutator(mctx BottomUpMutatorContext) {
a := module.base()
variableValues := reflect.ValueOf(&a.variableProperties.Product_variables).Elem()
zeroValues := reflect.ValueOf(zeroProductVariables.Product_variables)
+ valStruct := reflect.ValueOf(mctx.Config().productVariables)
+ doVariableMutation(mctx, a, variableValues, zeroValues, valStruct)
+
+}
+
+func doVariableMutation(mctx BottomUpMutatorContext, a *ModuleBase, variableValues reflect.Value, zeroValues reflect.Value,
+ valStruct reflect.Value) {
for i := 0; i < variableValues.NumField(); i++ {
variableValue := variableValues.Field(i)
zeroValue := zeroValues.Field(i)
@@ -362,8 +369,11 @@ func variableMutator(mctx BottomUpMutatorContext) {
property := "product_variables." + proptools.PropertyNameForField(name)
// Check that the variable was set for the product
- val := reflect.ValueOf(mctx.Config().productVariables).FieldByName(name)
- if !val.IsValid() || val.Kind() != reflect.Ptr || val.IsNil() {
+ val := valStruct.FieldByName(name)
+ if val.IsValid() && val.Kind() == reflect.Struct {
+ doVariableMutation(mctx, a, variableValue, zeroValue, val)
+ continue
+ } else if !val.IsValid() || val.Kind() != reflect.Ptr || val.IsNil() {
continue
}