Support proto.include_dirs
For each package in the include_dirs property a proto_library target should be added to the BUILD file in that package and a mapping should be added to the bp2build code, by this way a proper dependency relationship can be established and used by bazel. Bug: 239944064 Test: Added unit tests and manually verified include_dirs can be properly converted to bazel and used by bazel to build the targets. Change-Id: I50d8ee21fabcfec0a44487f6e5f3d8a3845e79c3
This commit is contained in:
@@ -2217,6 +2217,50 @@ func TestCcLibraryProtoExportHeaders(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibraryProtoIncludeDirs(t *testing.T) {
|
||||
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: "cc_library",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
Blueprint: soongCcProtoPreamble + `cc_library {
|
||||
name: "foo",
|
||||
srcs: ["foo.proto"],
|
||||
proto: {
|
||||
include_dirs: ["external/protobuf/src"],
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("proto_library", "foo_proto", AttrNameToString{
|
||||
"srcs": `["foo.proto"]`,
|
||||
"deps": `["//external/protobuf:libprotobuf-proto"]`,
|
||||
}), MakeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", AttrNameToString{
|
||||
"deps": `[":foo_proto"]`,
|
||||
}), MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
||||
"deps": `[":libprotobuf-cpp-lite"]`,
|
||||
"implementation_whole_archive_deps": `[":foo_cc_proto_lite"]`,
|
||||
}), MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||
"dynamic_deps": `[":libprotobuf-cpp-lite"]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibraryProtoIncludeDirsUnknown(t *testing.T) {
|
||||
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: "cc_library",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
Blueprint: soongCcProtoPreamble + `cc_library {
|
||||
name: "foo",
|
||||
srcs: ["foo.proto"],
|
||||
proto: {
|
||||
include_dirs: ["external/protobuf/abc"],
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
ExpectedErr: fmt.Errorf("module \"foo\": Could not find the proto_library target for include dir: external/protobuf/abc"),
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibraryProtoFilegroups(t *testing.T) {
|
||||
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: "cc_library",
|
||||
|
Reference in New Issue
Block a user