Add bp2build converter for python protobuf files
Bug: 196084681
Test: b run //build/bazel/examples/python/protobuf:build_bazel_examples_python_protobuf_main --config=linux_x86_64
Change-Id: I4d806902d262351231f64686a5d24513a25d9749
diff --git a/bp2build/python_library_conversion_test.go b/bp2build/python_library_conversion_test.go
index 66c2290..f51f106 100644
--- a/bp2build/python_library_conversion_test.go
+++ b/bp2build/python_library_conversion_test.go
@@ -305,3 +305,46 @@
},
})
}
+
+func TestPythonLibraryWithProtobufs(t *testing.T) {
+ runPythonLibraryTestCases(t, pythonLibBp2BuildTestCase{
+ description: "test %s protobuf",
+ filesystem: map[string]string{
+ "dir/mylib.py": "",
+ "dir/myproto.proto": "",
+ },
+ blueprint: `%s {
+ name: "foo",
+ srcs: [
+ "dir/mylib.py",
+ "dir/myproto.proto",
+ ],
+ }`,
+ expectedBazelTargets: []testBazelTarget{
+ {
+ typ: "proto_library",
+ name: "foo_proto",
+ attrs: attrNameToString{
+ "srcs": `["dir/myproto.proto"]`,
+ },
+ },
+ {
+ typ: "py_proto_library",
+ name: "foo_py_proto",
+ attrs: attrNameToString{
+ "deps": `[":foo_proto"]`,
+ },
+ },
+ {
+ typ: "py_library",
+ name: "foo",
+ attrs: attrNameToString{
+ "srcs": `["dir/mylib.py"]`,
+ "srcs_version": `"PY3"`,
+ "imports": `["."]`,
+ "deps": `[":foo_py_proto"]`,
+ },
+ },
+ },
+ })
+}