2017-10-05 140 views
1

我使用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_compilerules_protobufdocumented 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"]

回答