diff options
| author | 2021-05-10 11:39:53 -0400 | |
|---|---|---|
| committer | 2021-05-24 14:32:38 -0400 | |
| commit | e3e4a5f2d81068474fbd0a9907a8d1e85c20a310 (patch) | |
| tree | 2f8d8f0e68525a53b66a3bf9e4c28de0e66fbc70 /android/variable.go | |
| parent | 6fd7b3fee9fdf80126da91dbbb78e5d0d662402b (diff) | |
Handle arch/os-specific product variables
Bug: 183595873
Test: go test bp2build tests
Change-Id: I36e93ae1eb2943555dd304d5bdf62d995e77b437
Diffstat (limited to 'android/variable.go')
| -rw-r--r-- | android/variable.go | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/android/variable.go b/android/variable.go index 672576a9f..cf7493369 100644 --- a/android/variable.go +++ b/android/variable.go @@ -467,7 +467,7 @@ type ProductConfigProperties map[string][]ProductConfigProperty // ProductVariableProperties returns a ProductConfigProperties containing only the properties which // have been set for the module in the given context. -func ProductVariableProperties(ctx ProductConfigContext) ProductConfigProperties { +func ProductVariableProperties(ctx BaseMutatorContext) ProductConfigProperties { module := ctx.Module() moduleBase := module.base() @@ -477,7 +477,28 @@ func ProductVariableProperties(ctx ProductConfigContext) ProductConfigProperties return productConfigProperties } - variableValues := reflect.ValueOf(moduleBase.variableProperties).Elem().FieldByName("Product_variables") + productVariableValues(moduleBase.variableProperties, "", &productConfigProperties) + + for arch, targetProps := range moduleBase.GetArchProperties(ctx, moduleBase.variableProperties) { + // GetArchProperties is creating an instance of the requested type + // and productVariablesValues expects an interface, so no need to cast + productVariableValues(targetProps, arch.Name, &productConfigProperties) + } + + for os, targetProps := range moduleBase.GetTargetProperties(ctx, moduleBase.variableProperties) { + // GetTargetProperties is creating an instance of the requested type + // and productVariablesValues expects an interface, so no need to cast + productVariableValues(targetProps, os.Name, &productConfigProperties) + } + + return productConfigProperties +} + +func productVariableValues(variableProps interface{}, suffix string, productConfigProperties *ProductConfigProperties) { + if suffix != "" { + suffix = "-" + suffix + } + variableValues := reflect.ValueOf(variableProps).Elem().FieldByName("Product_variables") for i := 0; i < variableValues.NumField(); i++ { variableValue := variableValues.Field(i) // Check if any properties were set for the module @@ -495,15 +516,13 @@ func ProductVariableProperties(ctx ProductConfigContext) ProductConfigProperties // e.g. Asflags, Cflags, Enabled, etc. propertyName := variableValue.Type().Field(j).Name - productConfigProperties[propertyName] = append(productConfigProperties[propertyName], + (*productConfigProperties)[propertyName] = append((*productConfigProperties)[propertyName], ProductConfigProperty{ - ProductConfigVariable: productVariableName, + ProductConfigVariable: productVariableName + suffix, Property: property.Interface(), }) } } - - return productConfigProperties } func VariableMutator(mctx BottomUpMutatorContext) { |