bp2build for tidy_disabled_srcs
Bug: 195029134
Test: m bp2build
Change-Id: I9591439213dbf0ef68cd33151b3e32f6f6c68551
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 0d6d5b8..99d806c 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -3508,3 +3508,36 @@
},
})
}
+
+func TestCcLibraryWithTidy(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library uses tidy properties",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `
+cc_library_static {
+ name: "foo",
+ srcs: ["foo.cpp"],
+ tidy: true,
+ tidy_checks: ["check1", "check2"],
+ tidy_checks_as_errors: ["check1error", "check2error"],
+ tidy_disabled_srcs: ["bar.cpp"],
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
+ "local_includes": `["."]`,
+ "srcs": `["foo.cpp"]`,
+ "tidy": `True`,
+ "tidy_checks": `[
+ "check1",
+ "check2",
+ ]`,
+ "tidy_checks_as_errors": `[
+ "check1error",
+ "check2error",
+ ]`,
+ "tidy_disabled_srcs": `["bar.cpp"]`,
+ }),
+ },
+ })
+}
diff --git a/cc/binary.go b/cc/binary.go
index d09e744..c2868e7 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -646,7 +646,7 @@
sdkAttributes: bp2BuildParseSdkAttributes(m),
}
- m.convertTidyAttributes(&attrs.tidyAttributes)
+ m.convertTidyAttributes(ctx, &attrs.tidyAttributes)
return attrs
}
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 2f79cae..07e3d7f 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -75,9 +75,11 @@
Tidy_flags []string
Tidy_checks []string
Tidy_checks_as_errors []string
+ Tidy_disabled_srcs bazel.LabelListAttribute
+ // TODO(b/255754964) support Tidy_timeout_srcs
}
-func (m *Module) convertTidyAttributes(moduleAttrs *tidyAttributes) {
+func (m *Module) convertTidyAttributes(ctx android.BaseMutatorContext, moduleAttrs *tidyAttributes) {
for _, f := range m.features {
if tidy, ok := f.(*tidyFeature); ok {
moduleAttrs.Tidy = tidy.Properties.Tidy
@@ -85,6 +87,17 @@
moduleAttrs.Tidy_checks = tidy.Properties.Tidy_checks
moduleAttrs.Tidy_checks_as_errors = tidy.Properties.Tidy_checks_as_errors
}
+
+ }
+
+ archVariantProps := m.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
+ for axis, configToProps := range archVariantProps {
+ for config, _props := range configToProps {
+ if archProps, ok := _props.(*BaseCompilerProperties); ok {
+ archDisabledSrcs := android.BazelLabelForModuleSrc(ctx, archProps.Tidy_disabled_srcs)
+ moduleAttrs.Tidy_disabled_srcs.SetSelectValue(axis, config, archDisabledSrcs)
+ }
+ }
}
}
diff --git a/cc/library.go b/cc/library.go
index 41a68e3..79a22d6 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -2791,7 +2791,7 @@
Runtime_deps: linkerAttrs.runtimeDeps,
}
- module.convertTidyAttributes(&commonAttrs.tidyAttributes)
+ module.convertTidyAttributes(ctx, &commonAttrs.tidyAttributes)
var attrs interface{}
if isStatic {
diff --git a/cc/test.go b/cc/test.go
index 92055fa..536210b 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -678,7 +678,7 @@
}
}
- m.convertTidyAttributes(&testBinaryAttrs.tidyAttributes)
+ m.convertTidyAttributes(ctx, &testBinaryAttrs.tidyAttributes)
for _, propIntf := range m.GetProperties() {
if testLinkerProps, ok := propIntf.(*TestLinkerProperties); ok {