diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go index 9f6f45047..ef2ec32f3 100644 --- a/bp2build/cc_library_static_conversion_test.go +++ b/bp2build/cc_library_static_conversion_test.go @@ -986,6 +986,41 @@ cc_library_static { }) } +func TestCcLibraryStaticGeneratedHeadersAllPartitions(t *testing.T) { + runCcLibraryStaticTestCase(t, bp2buildTestCase{ + moduleTypeUnderTest: "cc_library_static", + moduleTypeUnderTestFactory: cc.LibraryStaticFactory, + moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, + blueprint: soongCcLibraryStaticPreamble + ` +genrule { + name: "generated_hdr", + cmd: "nothing to see here", +} + +cc_library_static { + name: "foo_static", + srcs: ["cpp_src.cpp", "as_src.S", "c_src.c"], + generated_headers: ["generated_hdr"], + include_build_directory: false, +}`, + expectedBazelTargets: []string{`cc_library_static( + name = "foo_static", + srcs = [ + "cpp_src.cpp", + ":generated_hdr", + ], + srcs_as = [ + "as_src.S", + ":generated_hdr", + ], + srcs_c = [ + "c_src.c", + ":generated_hdr", + ], +)`}, + }) +} + func TestCcLibraryStaticArchSrcsExcludeSrcsGeneratedFiles(t *testing.T) { runCcLibraryStaticTestCase(t, bp2buildTestCase{ description: "cc_library_static arch srcs/exclude_srcs with generated files", @@ -1067,10 +1102,10 @@ cc_library_static { name = "foo_static3", srcs = [ "common.cpp", - ":generated_hdr", - "//dep:generated_hdr_other_pkg", ":generated_src", "//dep:generated_src_other_pkg", + ":generated_hdr", + "//dep:generated_hdr_other_pkg", ] + select({ "//build/bazel/platforms/arch:x86": [ "for-x86.cpp", @@ -1082,8 +1117,8 @@ cc_library_static { ], }) + select({ "//build/bazel/platforms/os:android": [ - "//dep:generated_hdr_other_pkg_android", ":generated_src_android", + "//dep:generated_hdr_other_pkg_android", ], "//conditions:default": [], }), diff --git a/cc/bp2build.go b/cc/bp2build.go index c078096c7..a7cabcc85 100644 --- a/cc/bp2build.go +++ b/cc/bp2build.go @@ -26,6 +26,12 @@ import ( "github.com/google/blueprint/proptools" ) +const ( + cSrcPartition = "c" + asSrcPartition = "as" + cppSrcPartition = "cpp" +) + // staticOrSharedAttributes are the Bazel-ified versions of StaticOrSharedProperties -- // properties which apply to either the shared or static version of a cc_library module. type staticOrSharedAttributes struct { @@ -43,7 +49,7 @@ type staticOrSharedAttributes struct { System_dynamic_deps bazel.LabelListAttribute } -func groupSrcsByExtension(ctx android.TopDownMutatorContext, srcs bazel.LabelListAttribute) (cppSrcs, cSrcs, asSrcs bazel.LabelListAttribute) { +func groupSrcsByExtension(ctx android.TopDownMutatorContext, srcs bazel.LabelListAttribute) bazel.PartitionToLabelListAttribute { // Check that a module is a filegroup type named