Bp2build for errorprone modules that manually enabled/disabled it

Test: go test ./bp2build
Change-Id: Ie60c0959ee9ae8ce86c11a8e85a0bc7592f63df8
This commit is contained in:
Alix
2023-06-20 21:00:40 +00:00
parent c0dac52975
commit b1e5c6a69a
2 changed files with 46 additions and 24 deletions

View File

@@ -2765,11 +2765,12 @@ func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorConte
type javaCommonAttributes struct {
*javaResourcesAttributes
*kotlinAttributes
Srcs bazel.LabelListAttribute
Plugins bazel.LabelListAttribute
Javacopts bazel.StringListAttribute
Sdk_version bazel.StringAttribute
Java_version bazel.StringAttribute
Srcs bazel.LabelListAttribute
Plugins bazel.LabelListAttribute
Javacopts bazel.StringListAttribute
Sdk_version bazel.StringAttribute
Java_version bazel.StringAttribute
Errorprone_force_enable bazel.BoolAttribute
}
type javaDependencyLabels struct {
@@ -2911,26 +2912,35 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
staticDeps.Add(&bazel.Label{Label: ":" + javaAidlLibName})
}
var javacopts []string
var javacopts bazel.StringListAttribute //[]string
plugins := bazel.MakeLabelListAttribute(
android.BazelLabelForModuleDeps(ctx, m.properties.Plugins),
)
if m.properties.Javacflags != nil {
javacopts = append(javacopts, m.properties.Javacflags...)
javacopts = bazel.MakeStringListAttribute(m.properties.Javacflags)
}
epEnabled := m.properties.Errorprone.Enabled
//TODO(b/227504307) add configuration that depends on RUN_ERROR_PRONE environment variable
if Bool(epEnabled) {
javacopts = append(javacopts, m.properties.Errorprone.Javacflags...)
epJavacflags := m.properties.Errorprone.Javacflags
var errorproneForceEnable bazel.BoolAttribute
if epEnabled == nil {
//TODO(b/227504307) add configuration that depends on RUN_ERROR_PRONE environment variable
} else if *epEnabled {
plugins.Append(bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, m.properties.Errorprone.Extra_check_modules)))
javacopts.Append(bazel.MakeStringListAttribute(epJavacflags))
errorproneForceEnable.Value = epEnabled
} else {
javacopts.Append(bazel.MakeStringListAttribute([]string{"-XepDisableAllChecks"}))
}
commonAttrs := &javaCommonAttributes{
Srcs: javaSrcs,
javaResourcesAttributes: m.convertJavaResourcesAttributes(ctx),
Plugins: bazel.MakeLabelListAttribute(
android.BazelLabelForModuleDeps(ctx, m.properties.Plugins),
),
Javacopts: bazel.MakeStringListAttribute(javacopts),
Java_version: bazel.StringAttribute{Value: m.properties.Java_version},
Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version},
Plugins: plugins,
Javacopts: javacopts,
Java_version: bazel.StringAttribute{Value: m.properties.Java_version},
Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version},
Errorprone_force_enable: errorproneForceEnable,
}
for axis, configToProps := range archVariantProps {