我使用rules_protobuf为我的helloworld.proto
文件构建Python语言绑定。我的helloworld.proto
进口wrappers.proto。在Bazel BUILD中获取WORKSPACE根
syntax = "proto3";
package main;
import "google/protobuf/wrappers.proto";
我的生成文件
load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_compile")
# Wrapper around proto_compile.
# https://github.com/pubref/rules_protobuf/blob/master/protobuf/internal/proto_compile.bzl
py_proto_compile(
name = "py",
with_grpc = True,
protos = ["helloworld.proto"],
imports = ["/usr/local/home/username/myproject/include"]
)
的wrappers.proto
文件所在的目录
/usr/local/home/username/myproject/include
的巴泽尔规则py_proto_compile
由rules_protobuf和documented in the README.md定义。 imports
定义为:
- 名称:
imports
- 类型: string_list`
- 描述:可选路径为-I参数给protoc工具通过。
- 默认:
imports = ["/usr/local/home/username/myproject/include"]
巴泽勒不会出现任何:
[]
我的生成规则作品,但我已经通过硬编码的wrappers.proto
位置predefined Make variables引用我的WORKSPACE根。理想情况下,我想这样做:
imports = ["$WORKSPACE_ROOT"/include"]