Make bp2build-generated selects() based on product config build settings
...instead of based on constraint settings.
Bug: 269577299
Test: m nothing and ./build/bazel/ci/bp2build.sh
Change-Id: Ib9caec79c92b8fd304e46be841de5612bd1637e3
diff --git a/android/module.go b/android/module.go
index 4c781f6..b982019 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1373,15 +1373,15 @@
}
}
- productConfigEnabledLabels := []bazel.Label{}
+ productConfigEnabledAttribute := bazel.LabelListAttribute{}
// TODO(b/234497586): Soong config variables and product variables have different overriding behavior, we
// should handle it correctly
if !proptools.BoolDefault(enabledProperty.Value, true) && !neitherHostNorDevice {
// If the module is not enabled by default, then we can check if a
// product variable enables it
- productConfigEnabledLabels = productVariableConfigEnableLabels(ctx)
+ productConfigEnabledAttribute = productVariableConfigEnableAttribute(ctx)
- if len(productConfigEnabledLabels) > 0 {
+ if len(productConfigEnabledAttribute.ConfigurableValues) > 0 {
// In this case, an existing product variable configuration overrides any
// module-level `enable: false` definition
newValue := true
@@ -1389,10 +1389,6 @@
}
}
- productConfigEnabledAttribute := bazel.MakeLabelListAttribute(bazel.LabelList{
- productConfigEnabledLabels, nil,
- })
-
platformEnabledAttribute, err := enabledProperty.ToLabelListAttribute(
bazel.LabelList{[]bazel.Label{{Label: "@platforms//:incompatible"}}, nil},
bazel.LabelList{[]bazel.Label{}, nil})
@@ -1423,31 +1419,28 @@
// Check product variables for `enabled: true` flag override.
// Returns a list of the constraint_value targets who enable this override.
-func productVariableConfigEnableLabels(ctx *topDownMutatorContext) []bazel.Label {
+func productVariableConfigEnableAttribute(ctx *topDownMutatorContext) bazel.LabelListAttribute {
+ result := bazel.LabelListAttribute{}
productVariableProps := ProductVariableProperties(ctx, ctx.Module())
- productConfigEnablingTargets := []bazel.Label{}
- const propName = "Enabled"
- if productConfigProps, exists := productVariableProps[propName]; exists {
+ if productConfigProps, exists := productVariableProps["Enabled"]; exists {
for productConfigProp, prop := range productConfigProps {
flag, ok := prop.(*bool)
if !ok {
- ctx.ModuleErrorf("Could not convert product variable %s property", proptools.PropertyNameForField(propName))
+ ctx.ModuleErrorf("Could not convert product variable enabled property")
}
if *flag {
axis := productConfigProp.ConfigurationAxis()
- targetLabel := axis.SelectKey(productConfigProp.SelectKey())
- productConfigEnablingTargets = append(productConfigEnablingTargets, bazel.Label{
- Label: targetLabel,
- })
+ result.SetSelectValue(axis, bazel.ConditionsDefaultConfigKey, bazel.MakeLabelList([]bazel.Label{{Label: "@platforms//:incompatible"}}))
+ result.SetSelectValue(axis, productConfigProp.SelectKey(), bazel.LabelList{Includes: []bazel.Label{}})
} else {
// TODO(b/210546943): handle negative case where `enabled: false`
- ctx.ModuleErrorf("`enabled: false` is not currently supported for configuration variables. See b/210546943", proptools.PropertyNameForField(propName))
+ ctx.ModuleErrorf("`enabled: false` is not currently supported for configuration variables. See b/210546943")
}
}
}
- return productConfigEnablingTargets
+ return result
}
// A ModuleBase object contains the properties that are common to all Android