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
This commit is contained in:
Cole Faust
2022-05-12 15:37:02 -07:00
parent ec6c065af6
commit 53b62098d0
5 changed files with 78 additions and 3 deletions

View File

@@ -305,3 +305,46 @@ func TestPythonArchVariance(t *testing.T) {
},
})
}
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"]`,
},
},
},
})
}