Make errorprone a configurable attribute for bazel conversion

Change-Id: Icf2265e9f712c3255321456e977928163696dc22
Test: ./bp22build tests in child commit
This commit is contained in:
Alix 2023-05-04 21:20:16 +00:00
parent 3875e1c582
commit c0dac52975
2 changed files with 28 additions and 11 deletions

View file

@ -74,6 +74,8 @@ const (
InApex = "in_apex"
NonApex = "non_apex"
ErrorproneDisabled = "errorprone_disabled"
)
func PowerSetWithoutEmptySet[T any](items []T) [][]T {
@ -216,6 +218,11 @@ var (
NonApex: "//build/bazel/rules/apex:non_apex",
ConditionsDefaultConfigKey: ConditionsDefaultSelectKey,
}
errorProneMap = map[string]string{
ErrorproneDisabled: "//build/bazel/rules/java/errorprone:errorprone_globally_disabled",
ConditionsDefaultConfigKey: ConditionsDefaultSelectKey,
}
)
// basic configuration types
@ -229,6 +236,7 @@ const (
productVariables
osAndInApex
inApex
errorProneDisabled
)
func osArchString(os string, arch string) string {
@ -237,13 +245,14 @@ func osArchString(os string, arch string) string {
func (ct configurationType) String() string {
return map[configurationType]string{
noConfig: "no_config",
arch: "arch",
os: "os",
osArch: "arch_os",
productVariables: "product_variables",
osAndInApex: "os_in_apex",
inApex: "in_apex",
noConfig: "no_config",
arch: "arch",
os: "os",
osArch: "arch_os",
productVariables: "product_variables",
osAndInApex: "os_in_apex",
inApex: "in_apex",
errorProneDisabled: "errorprone_disabled",
}[ct]
}
@ -274,6 +283,10 @@ func (ct configurationType) validateConfig(config string) {
if _, ok := inApexMap[config]; !ok {
panic(fmt.Errorf("Unknown in_apex config: %s", config))
}
case errorProneDisabled:
if _, ok := errorProneMap[config]; !ok {
panic(fmt.Errorf("Unknown errorprone config: %s", config))
}
default:
panic(fmt.Errorf("Unrecognized ConfigurationType %d", ct))
}
@ -303,6 +316,8 @@ func (ca ConfigurationAxis) SelectKey(config string) string {
return config
case inApex:
return inApexMap[config]
case errorProneDisabled:
return errorProneMap[config]
default:
panic(fmt.Errorf("Unrecognized ConfigurationType %d", ca.configurationType))
}
@ -321,6 +336,8 @@ var (
OsAndInApexAxis = ConfigurationAxis{configurationType: osAndInApex}
// An axis for in_apex-specific configurations
InApexAxis = ConfigurationAxis{configurationType: inApex}
ErrorProneAxis = ConfigurationAxis{configurationType: errorProneDisabled}
)
// ProductVariableConfigurationAxis returns an axis for the given product variable

View file

@ -766,7 +766,7 @@ func (lla *LabelListAttribute) SetSelectValue(axis ConfigurationAxis, config str
switch axis.configurationType {
case noConfig:
lla.Value = list
case arch, os, osArch, productVariables, osAndInApex, inApex:
case arch, os, osArch, productVariables, osAndInApex, inApex, errorProneDisabled:
if lla.ConfigurableValues == nil {
lla.ConfigurableValues = make(configurableLabelLists)
}
@ -782,7 +782,7 @@ func (lla *LabelListAttribute) SelectValue(axis ConfigurationAxis, config string
switch axis.configurationType {
case noConfig:
return lla.Value
case arch, os, osArch, productVariables, osAndInApex, inApex:
case arch, os, osArch, productVariables, osAndInApex, inApex, errorProneDisabled:
return lla.ConfigurableValues[axis][config]
default:
panic(fmt.Errorf("Unrecognized ConfigurationAxis %s", axis))
@ -1346,7 +1346,7 @@ func (sla *StringListAttribute) SetSelectValue(axis ConfigurationAxis, config st
switch axis.configurationType {
case noConfig:
sla.Value = list
case arch, os, osArch, productVariables, osAndInApex:
case arch, os, osArch, productVariables, osAndInApex, errorProneDisabled:
if sla.ConfigurableValues == nil {
sla.ConfigurableValues = make(configurableStringLists)
}
@ -1362,7 +1362,7 @@ func (sla *StringListAttribute) SelectValue(axis ConfigurationAxis, config strin
switch axis.configurationType {
case noConfig:
return sla.Value
case arch, os, osArch, productVariables, osAndInApex:
case arch, os, osArch, productVariables, osAndInApex, errorProneDisabled:
return sla.ConfigurableValues[axis][config]
default:
panic(fmt.Errorf("Unrecognized ConfigurationAxis %s", axis))