Add support for merging defaults soong_config_module_types into bp2build am: 84817de033
am: 03eb2b1774
am: 07415f907f
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1894966 Change-Id: If726a8e907ec715d970ce77acd7fa6548a6f73d3
This commit is contained in:
@@ -642,13 +642,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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,7 +669,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 (
|
||||
@@ -703,19 +717,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: {
|
||||
@@ -836,6 +841,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