Bp2build support for soong config variables + os
For converting the art plugins to pure soong, it would be useful to have a property that's qualified on both a soong config variable and the OS. Soong had very little-known support for this by saying your soong config variable changes the "target.android.cflags" property, and we didn't supporting bp2building that. Add the bp2build support. This cl also refactors product variable and soong variable bp2building so that they're separate from each other, which I think makes the code easier to understand. Test: go test Change-Id: Ic74dc75da8103fa2523da95c3560c9ce3c5e5672
This commit is contained in:
@@ -292,8 +292,7 @@ func (ca ConfigurationAxis) SelectKey(config string) string {
|
||||
case osArch:
|
||||
return platformOsArchMap[config]
|
||||
case productVariables:
|
||||
if strings.HasSuffix(config, ConditionsDefaultConfigKey) {
|
||||
// e.g. "acme__feature1__conditions_default" or "android__board__conditions_default"
|
||||
if config == ConditionsDefaultConfigKey {
|
||||
return ConditionsDefaultSelectKey
|
||||
}
|
||||
return fmt.Sprintf("%s:%s", productVariableBazelPackage, config)
|
||||
@@ -325,11 +324,11 @@ var (
|
||||
)
|
||||
|
||||
// ProductVariableConfigurationAxis returns an axis for the given product variable
|
||||
func ProductVariableConfigurationAxis(variable string, outerAxis ConfigurationAxis) ConfigurationAxis {
|
||||
func ProductVariableConfigurationAxis(archVariant bool, variable string) ConfigurationAxis {
|
||||
return ConfigurationAxis{
|
||||
configurationType: productVariables,
|
||||
subType: variable,
|
||||
outerAxisType: outerAxis.configurationType,
|
||||
archVariant: archVariant,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,8 +339,8 @@ type ConfigurationAxis struct {
|
||||
// some configuration types (e.g. productVariables) have multiple independent axes, subType helps
|
||||
// distinguish between them without needing to list all 17 product variables.
|
||||
subType string
|
||||
// used to keep track of which product variables are arch variant
|
||||
outerAxisType configurationType
|
||||
|
||||
archVariant bool
|
||||
}
|
||||
|
||||
func (ca *ConfigurationAxis) less(other ConfigurationAxis) bool {
|
||||
|
@@ -334,7 +334,7 @@ func (la *LabelAttribute) Collapse() error {
|
||||
if containsArch {
|
||||
allProductVariablesAreArchVariant := true
|
||||
for k := range la.ConfigurableValues {
|
||||
if k.configurationType == productVariables && k.outerAxisType != arch {
|
||||
if k.configurationType == productVariables && !k.archVariant {
|
||||
allProductVariablesAreArchVariant = false
|
||||
}
|
||||
}
|
||||
|
@@ -248,13 +248,13 @@ func TestResolveExcludes(t *testing.T) {
|
||||
OsArchConfigurationAxis: labelListSelectValues{
|
||||
"linux_x86": makeLabelList([]string{"linux_x86_include"}, []string{}),
|
||||
},
|
||||
ProductVariableConfigurationAxis("product_with_defaults", NoConfigAxis): labelListSelectValues{
|
||||
ProductVariableConfigurationAxis(false, "product_with_defaults"): labelListSelectValues{
|
||||
"a": makeLabelList([]string{}, []string{"not_in_value"}),
|
||||
"b": makeLabelList([]string{"b_val"}, []string{}),
|
||||
"c": makeLabelList([]string{"c_val"}, []string{}),
|
||||
ConditionsDefaultConfigKey: makeLabelList([]string{"c_val", "default", "default2", "all_exclude"}, []string{}),
|
||||
},
|
||||
ProductVariableConfigurationAxis("product_only_with_excludes", NoConfigAxis): labelListSelectValues{
|
||||
ProductVariableConfigurationAxis(false, "product_only_with_excludes"): labelListSelectValues{
|
||||
"a": makeLabelList([]string{}, []string{"product_config_exclude"}),
|
||||
},
|
||||
},
|
||||
@@ -282,13 +282,13 @@ func TestResolveExcludes(t *testing.T) {
|
||||
"linux_x86": makeLabels("linux_x86_include"),
|
||||
ConditionsDefaultConfigKey: nilLabels,
|
||||
},
|
||||
ProductVariableConfigurationAxis("product_with_defaults", NoConfigAxis): {
|
||||
ProductVariableConfigurationAxis(false, "product_with_defaults"): {
|
||||
"a": nilLabels,
|
||||
"b": makeLabels("b_val"),
|
||||
"c": makeLabels("c_val"),
|
||||
ConditionsDefaultConfigKey: makeLabels("c_val", "default", "default2"),
|
||||
},
|
||||
ProductVariableConfigurationAxis("product_only_with_excludes", NoConfigAxis): {
|
||||
ProductVariableConfigurationAxis(false, "product_only_with_excludes"): {
|
||||
"a": nilLabels,
|
||||
ConditionsDefaultConfigKey: makeLabels("product_config_exclude"),
|
||||
},
|
||||
@@ -679,7 +679,7 @@ func TestDeduplicateAxesFromBase(t *testing.T) {
|
||||
OsArchConfigurationAxis: stringListSelectValues{
|
||||
"linux_x86": {"linux_x86_include"},
|
||||
},
|
||||
ProductVariableConfigurationAxis("a", NoConfigAxis): stringListSelectValues{
|
||||
ProductVariableConfigurationAxis(false, "a"): stringListSelectValues{
|
||||
"a": []string{"not_in_value"},
|
||||
},
|
||||
},
|
||||
@@ -704,7 +704,7 @@ func TestDeduplicateAxesFromBase(t *testing.T) {
|
||||
"linux": []string{"linux_include"},
|
||||
},
|
||||
OsArchConfigurationAxis: stringListSelectValues{},
|
||||
ProductVariableConfigurationAxis("a", NoConfigAxis): stringListSelectValues{
|
||||
ProductVariableConfigurationAxis(false, "a"): stringListSelectValues{
|
||||
"a": []string{"not_in_value"},
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user