Add support for merging defaults soong_config_module_types into bp2build am: 84817de033
am: 03eb2b1774
am: 07415f907f
am: 43e834945b
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1894966 Change-Id: I0f3e8cd92aa6ace3e7b3f6b50fc4c4672064eed3
This commit is contained in:
@@ -643,13 +643,15 @@ func ProductVariableProperties(ctx BazelConversionPathContext) ProductConfigProp
|
||||
}
|
||||
|
||||
if m, ok := module.(Bazelable); ok && m.namespacedVariableProps() != nil {
|
||||
for namespace, namespacedVariableProp := range m.namespacedVariableProps() {
|
||||
productVariableValues(
|
||||
soongconfig.SoongConfigProperty,
|
||||
namespacedVariableProp,
|
||||
namespace,
|
||||
"",
|
||||
&productConfigProperties)
|
||||
for namespace, namespacedVariableProps := range m.namespacedVariableProps() {
|
||||
for _, namespacedVariableProp := range namespacedVariableProps {
|
||||
productVariableValues(
|
||||
soongconfig.SoongConfigProperty,
|
||||
namespacedVariableProp,
|
||||
namespace,
|
||||
"",
|
||||
&productConfigProperties)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -668,7 +670,19 @@ func (p *ProductConfigProperties) AddProductConfigProperty(
|
||||
FullConfig: config, // e.g. size, feature1-x86, size__conditions_default
|
||||
}
|
||||
|
||||
(*p)[propertyName][productConfigProp] = property
|
||||
if existing, ok := (*p)[propertyName][productConfigProp]; ok && namespace != "" {
|
||||
switch dst := existing.(type) {
|
||||
case []string:
|
||||
if src, ok := property.([]string); ok {
|
||||
dst = append(dst, src...)
|
||||
(*p)[propertyName][productConfigProp] = dst
|
||||
}
|
||||
default:
|
||||
// TODO(jingwen): Add support for more types.
|
||||
}
|
||||
} else {
|
||||
(*p)[propertyName][productConfigProp] = property
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -704,19 +718,10 @@ func maybeExtractConfigVarProp(v reflect.Value) (reflect.Value, bool) {
|
||||
return v, true
|
||||
}
|
||||
|
||||
// productVariableValues uses reflection to convert a property struct for
|
||||
// product_variables and soong_config_variables to structs that can be generated
|
||||
// as select statements.
|
||||
func productVariableValues(
|
||||
fieldName string, variableProps interface{}, namespace, suffix string, productConfigProperties *ProductConfigProperties) {
|
||||
if suffix != "" {
|
||||
suffix = "-" + suffix
|
||||
}
|
||||
|
||||
// variableValues represent the product_variables or soong_config_variables
|
||||
// struct.
|
||||
variableValues := reflect.ValueOf(variableProps).Elem().FieldByName(fieldName)
|
||||
|
||||
func (productConfigProperties *ProductConfigProperties) AddProductConfigProperties(namespace, suffix string, variableValues reflect.Value) {
|
||||
// variableValues can either be a product_variables or
|
||||
// soong_config_variables struct.
|
||||
//
|
||||
// Example of product_variables:
|
||||
//
|
||||
// product_variables: {
|
||||
@@ -837,6 +842,20 @@ func productVariableValues(
|
||||
}
|
||||
}
|
||||
|
||||
// productVariableValues uses reflection to convert a property struct for
|
||||
// product_variables and soong_config_variables to structs that can be generated
|
||||
// as select statements.
|
||||
func productVariableValues(
|
||||
fieldName string, variableProps interface{}, namespace, suffix string, productConfigProperties *ProductConfigProperties) {
|
||||
if suffix != "" {
|
||||
suffix = "-" + suffix
|
||||
}
|
||||
|
||||
// variableValues represent the product_variables or soong_config_variables struct.
|
||||
variableValues := reflect.ValueOf(variableProps).Elem().FieldByName(fieldName)
|
||||
productConfigProperties.AddProductConfigProperties(namespace, suffix, variableValues)
|
||||
}
|
||||
|
||||
func VariableMutator(mctx BottomUpMutatorContext) {
|
||||
var module Module
|
||||
var ok bool
|
||||
|
Reference in New Issue
Block a user