Merge "Don't panic for unhandled product vars" into main
This commit is contained in:
@@ -1458,7 +1458,10 @@ func addCompatibilityConstraintForCompileMultilib(ctx *topDownMutatorContext, en
|
|||||||
// Returns a list of the constraint_value targets who enable this override.
|
// Returns a list of the constraint_value targets who enable this override.
|
||||||
func productVariableConfigEnableAttribute(ctx *topDownMutatorContext) bazel.LabelListAttribute {
|
func productVariableConfigEnableAttribute(ctx *topDownMutatorContext) bazel.LabelListAttribute {
|
||||||
result := bazel.LabelListAttribute{}
|
result := bazel.LabelListAttribute{}
|
||||||
productVariableProps := ProductVariableProperties(ctx, ctx.Module())
|
productVariableProps, errs := ProductVariableProperties(ctx, ctx.Module())
|
||||||
|
for _, err := range errs {
|
||||||
|
ctx.ModuleErrorf("ProductVariableProperties error: %s", err)
|
||||||
|
}
|
||||||
if productConfigProps, exists := productVariableProps["Enabled"]; exists {
|
if productConfigProps, exists := productVariableProps["Enabled"]; exists {
|
||||||
for productConfigProp, prop := range productConfigProps {
|
for productConfigProp, prop := range productConfigProps {
|
||||||
flag, ok := prop.(*bool)
|
flag, ok := prop.(*bool)
|
||||||
|
@@ -675,7 +675,8 @@ type ProductConfigProperties map[string]map[ProductConfigOrSoongConfigProperty]i
|
|||||||
|
|
||||||
// ProductVariableProperties returns a ProductConfigProperties containing only the properties which
|
// ProductVariableProperties returns a ProductConfigProperties containing only the properties which
|
||||||
// have been set for the given module.
|
// have been set for the given module.
|
||||||
func ProductVariableProperties(ctx ArchVariantContext, module Module) ProductConfigProperties {
|
func ProductVariableProperties(ctx ArchVariantContext, module Module) (ProductConfigProperties, []error) {
|
||||||
|
var errs []error
|
||||||
moduleBase := module.base()
|
moduleBase := module.base()
|
||||||
|
|
||||||
productConfigProperties := ProductConfigProperties{}
|
productConfigProperties := ProductConfigProperties{}
|
||||||
@@ -699,12 +700,15 @@ func ProductVariableProperties(ctx ArchVariantContext, module Module) ProductCon
|
|||||||
for namespace, namespacedVariableProps := range m.namespacedVariableProps() {
|
for namespace, namespacedVariableProps := range m.namespacedVariableProps() {
|
||||||
for _, namespacedVariableProp := range namespacedVariableProps {
|
for _, namespacedVariableProp := range namespacedVariableProps {
|
||||||
variableValues := reflect.ValueOf(namespacedVariableProp).Elem().FieldByName(soongconfig.SoongConfigProperty)
|
variableValues := reflect.ValueOf(namespacedVariableProp).Elem().FieldByName(soongconfig.SoongConfigProperty)
|
||||||
productConfigProperties.AddSoongConfigProperties(namespace, variableValues)
|
err := productConfigProperties.AddSoongConfigProperties(namespace, variableValues)
|
||||||
|
if err != nil {
|
||||||
|
errs = append(errs, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return productConfigProperties
|
return productConfigProperties, errs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ProductConfigProperties) AddProductConfigProperty(
|
func (p *ProductConfigProperties) AddProductConfigProperty(
|
||||||
@@ -826,7 +830,7 @@ func (productConfigProperties *ProductConfigProperties) AddProductConfigProperti
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (productConfigProperties *ProductConfigProperties) AddSoongConfigProperties(namespace string, soongConfigVariablesStruct reflect.Value) {
|
func (productConfigProperties *ProductConfigProperties) AddSoongConfigProperties(namespace string, soongConfigVariablesStruct reflect.Value) error {
|
||||||
//
|
//
|
||||||
// Example of soong_config_variables:
|
// Example of soong_config_variables:
|
||||||
//
|
//
|
||||||
@@ -923,7 +927,7 @@ func (productConfigProperties *ProductConfigProperties) AddSoongConfigProperties
|
|||||||
if propertyName == "Target" {
|
if propertyName == "Target" {
|
||||||
productConfigProperties.AddSoongConfigPropertiesFromTargetStruct(namespace, variableName, proptools.PropertyNameForField(propertyOrValueName), field.Field(k))
|
productConfigProperties.AddSoongConfigPropertiesFromTargetStruct(namespace, variableName, proptools.PropertyNameForField(propertyOrValueName), field.Field(k))
|
||||||
} else if propertyName == "Arch" || propertyName == "Multilib" {
|
} else if propertyName == "Arch" || propertyName == "Multilib" {
|
||||||
panic("Arch/Multilib are not currently supported in soong config variable structs")
|
return fmt.Errorf("Arch/Multilib are not currently supported in soong config variable structs")
|
||||||
} else {
|
} else {
|
||||||
productConfigProperties.AddSoongConfigProperty(propertyName, namespace, variableName, proptools.PropertyNameForField(propertyOrValueName), "", field.Field(k).Interface())
|
productConfigProperties.AddSoongConfigProperty(propertyName, namespace, variableName, proptools.PropertyNameForField(propertyOrValueName), "", field.Field(k).Interface())
|
||||||
}
|
}
|
||||||
@@ -934,13 +938,14 @@ func (productConfigProperties *ProductConfigProperties) AddSoongConfigProperties
|
|||||||
if propertyOrValueName == "Target" {
|
if propertyOrValueName == "Target" {
|
||||||
productConfigProperties.AddSoongConfigPropertiesFromTargetStruct(namespace, variableName, "", propertyOrStruct)
|
productConfigProperties.AddSoongConfigPropertiesFromTargetStruct(namespace, variableName, "", propertyOrStruct)
|
||||||
} else if propertyOrValueName == "Arch" || propertyOrValueName == "Multilib" {
|
} else if propertyOrValueName == "Arch" || propertyOrValueName == "Multilib" {
|
||||||
panic("Arch/Multilib are not currently supported in soong config variable structs")
|
return fmt.Errorf("Arch/Multilib are not currently supported in soong config variable structs")
|
||||||
} else {
|
} else {
|
||||||
productConfigProperties.AddSoongConfigProperty(propertyOrValueName, namespace, variableName, "", "", propertyOrStruct.Interface())
|
productConfigProperties.AddSoongConfigProperty(propertyOrValueName, namespace, variableName, "", "", propertyOrStruct.Interface())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (productConfigProperties *ProductConfigProperties) AddSoongConfigPropertiesFromTargetStruct(namespace, soongConfigVariableName string, soongConfigVariableValue string, targetStruct reflect.Value) {
|
func (productConfigProperties *ProductConfigProperties) AddSoongConfigPropertiesFromTargetStruct(namespace, soongConfigVariableName string, soongConfigVariableValue string, targetStruct reflect.Value) {
|
||||||
|
@@ -3298,7 +3298,10 @@ func convertWithBp2build(a *apexBundle, ctx android.TopDownMutatorContext) (baze
|
|||||||
cannedFsConfigAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *a.properties.Canned_fs_config))
|
cannedFsConfigAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *a.properties.Canned_fs_config))
|
||||||
}
|
}
|
||||||
|
|
||||||
productVariableProps := android.ProductVariableProperties(ctx, a)
|
productVariableProps, errs := android.ProductVariableProperties(ctx, a)
|
||||||
|
for _, err := range errs {
|
||||||
|
ctx.ModuleErrorf("ProductVariableProperties error: %s", err)
|
||||||
|
}
|
||||||
// TODO(b/219503907) this would need to be set to a.MinSdkVersionValue(ctx) but
|
// TODO(b/219503907) this would need to be set to a.MinSdkVersionValue(ctx) but
|
||||||
// given it's coming via config, we probably don't want to put it in here.
|
// given it's coming via config, we probably don't want to put it in here.
|
||||||
var minSdkVersion bazel.StringAttribute
|
var minSdkVersion bazel.StringAttribute
|
||||||
|
@@ -517,7 +517,10 @@ func (m *customModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
productVariableProps := android.ProductVariableProperties(ctx, ctx.Module())
|
productVariableProps, errs := android.ProductVariableProperties(ctx, ctx.Module())
|
||||||
|
for _, err := range errs {
|
||||||
|
ctx.ModuleErrorf("ProductVariableProperties error: %s", err)
|
||||||
|
}
|
||||||
if props, ok := productVariableProps["String_literal_prop"]; ok {
|
if props, ok := productVariableProps["String_literal_prop"]; ok {
|
||||||
for c, p := range props {
|
for c, p := range props {
|
||||||
if val, ok := p.(*string); ok {
|
if val, ok := p.(*string); ok {
|
||||||
|
@@ -944,7 +944,10 @@ func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module)
|
|||||||
nativeCoverage = BoolPtr(false)
|
nativeCoverage = BoolPtr(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
productVariableProps := android.ProductVariableProperties(ctx, ctx.Module())
|
productVariableProps, errs := android.ProductVariableProperties(ctx, ctx.Module())
|
||||||
|
for _, err := range errs {
|
||||||
|
ctx.ModuleErrorf("ProductVariableProperties error: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
(&compilerAttrs).convertProductVariables(ctx, productVariableProps)
|
(&compilerAttrs).convertProductVariables(ctx, productVariableProps)
|
||||||
(&linkerAttrs).convertProductVariables(ctx, productVariableProps)
|
(&linkerAttrs).convertProductVariables(ctx, productVariableProps)
|
||||||
|
@@ -730,8 +730,11 @@ func (module *PrebuiltEtc) Bp2buildHelper(ctx android.TopDownMutatorContext) (*b
|
|||||||
src.SetSelectValue(axis, config, label)
|
src.SetSelectValue(axis, config, label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
productVarProperties, errs := android.ProductVariableProperties(ctx, ctx.Module())
|
||||||
for propName, productConfigProps := range android.ProductVariableProperties(ctx, ctx.Module()) {
|
for _, err := range errs {
|
||||||
|
ctx.ModuleErrorf("ProductVariableProperties error: %s", err)
|
||||||
|
}
|
||||||
|
for propName, productConfigProps := range productVarProperties {
|
||||||
for configProp, propVal := range productConfigProps {
|
for configProp, propVal := range productConfigProps {
|
||||||
if propName == "Src" {
|
if propName == "Src" {
|
||||||
props, ok := propVal.(*string)
|
props, ok := propVal.(*string)
|
||||||
|
@@ -993,7 +993,10 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
|||||||
|
|
||||||
var cmdProp bazel.StringAttribute
|
var cmdProp bazel.StringAttribute
|
||||||
cmdProp.SetValue(replaceVariables(proptools.String(m.properties.Cmd)))
|
cmdProp.SetValue(replaceVariables(proptools.String(m.properties.Cmd)))
|
||||||
allProductVariableProps := android.ProductVariableProperties(ctx, m)
|
allProductVariableProps, errs := android.ProductVariableProperties(ctx, m)
|
||||||
|
for _, err := range errs {
|
||||||
|
ctx.ModuleErrorf("ProductVariableProperties error: %s", err)
|
||||||
|
}
|
||||||
if productVariableProps, ok := allProductVariableProps["Cmd"]; ok {
|
if productVariableProps, ok := allProductVariableProps["Cmd"]; ok {
|
||||||
for productVariable, value := range productVariableProps {
|
for productVariable, value := range productVariableProps {
|
||||||
var cmd string
|
var cmd string
|
||||||
|
Reference in New Issue
Block a user