summaryrefslogtreecommitdiff
path: root/android/variable.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/variable.go')
-rw-r--r--android/variable.go26
1 files changed, 19 insertions, 7 deletions
diff --git a/android/variable.go b/android/variable.go
index 9625a879a..58e59404e 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -25,7 +25,7 @@ import (
func init() {
PreDepsMutators(func(ctx RegisterMutatorsContext) {
- ctx.BottomUp("variable", variableMutator).Parallel()
+ ctx.BottomUp("variable", VariableMutator).Parallel()
})
}
@@ -127,13 +127,14 @@ type variableProperties struct {
} `android:"arch_variant"`
Native_coverage struct {
+ Src *string `android:"arch_variant"`
Srcs []string `android:"arch_variant"`
Exclude_srcs []string `android:"arch_variant"`
} `android:"arch_variant"`
} `android:"arch_variant"`
}
-var zeroProductVariables interface{} = variableProperties{}
+var defaultProductVariables interface{} = variableProperties{}
type productVariables struct {
// Suffix to add to generated Makefiles
@@ -384,7 +385,7 @@ func (v *productVariables) SetDefaultConfig() {
}
}
-func variableMutator(mctx BottomUpMutatorContext) {
+func VariableMutator(mctx BottomUpMutatorContext) {
var module Module
var ok bool
if module, ok = mctx.Module().(Module); !ok {
@@ -399,11 +400,9 @@ func variableMutator(mctx BottomUpMutatorContext) {
}
variableValues := reflect.ValueOf(a.variableProperties).Elem().FieldByName("Product_variables")
- zeroValues := reflect.ValueOf(zeroProductVariables).FieldByName("Product_variables")
for i := 0; i < variableValues.NumField(); i++ {
variableValue := variableValues.Field(i)
- zeroValue := zeroValues.Field(i)
name := variableValues.Type().Field(i).Name
property := "product_variables." + proptools.PropertyNameForField(name)
@@ -421,10 +420,9 @@ func variableMutator(mctx BottomUpMutatorContext) {
}
// Check if any properties were set for the module
- if reflect.DeepEqual(variableValue.Interface(), zeroValue.Interface()) {
+ if variableValue.IsZero() {
continue
}
-
a.setVariableProperties(mctx, property, variableValue, val.Interface())
}
}
@@ -542,6 +540,20 @@ func sliceToTypeArray(s []interface{}) interface{} {
return ret.Interface()
}
+func initProductVariableModule(m Module) {
+ base := m.base()
+
+ // Allow tests to override the default product variables
+ if base.variableProperties == nil {
+ base.variableProperties = defaultProductVariables
+ }
+ // Filter the product variables properties to the ones that exist on this module
+ base.variableProperties = createVariableProperties(m.GetProperties(), base.variableProperties)
+ if base.variableProperties != nil {
+ m.AddProperties(base.variableProperties)
+ }
+}
+
// createVariableProperties takes the list of property structs for a module and returns a property struct that
// contains the product variable properties that exist in the property structs, or nil if there are none. It
// caches the result.