Hello Bazel-discuss.
I have a proto definition which has `import "google/rpc/status.proto";`
What is the idiomatic/efficient/correct way for defining a Bazel `go_proto_library()` rule? Currently my **working** `BUILD` file is:
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library", "GRPC_COMPILE_DEPS")
go_proto_library(
name = "protolib",
protos = glob(["*.proto"]),
verbose = 1,
visibility = ["//visibility:public"],
with_grpc = True,
#
# Used to define how the generate pb.go file will generate the
# go import statement.
#
#
# importmap = {
# },
#
# The --proto_path option of protoc compiler.
# the external is-i think-the bazel magic of where the external .proto files are placed.
#
imports = [
"external/com_google_protobuf/src",
"external/googleapi",
],
#
# any.proto and google/rpc/status.proto inclusing in the .proto file.
#
inputs = [
"@com_google_protobuf//:well_known_protos",
"@googleapi//:rpc_status_protos_src",
],
#
# pb.go file dependencies
#
deps = [ "@org_golang_google_genproto//googleapis/rpc/status:go_default_library",
],
)
The relevant pieces of the `WORKSPACE` file are:
#
# Needed for gathering the pb.go's dependency on gRPC status.pb.go
#
go_repository(
name = "org_golang_google_genproto",
)
## Needed for including google/grpc/status.proto in a protobuf definition
GOOGLEAPIS_SHA="5c6df0cd18c6a429eab739fb711c27f6e1393366" # May 14, 2017
new_http_archive(
name = "googleapi",
strip_prefix = "googleapis-" + GOOGLEAPIS_SHA,
urls = [
],
build_file_content = """
load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library")
filegroup(
name = "rpc_status_protos_src",
srcs = [
"google/rpc/status.proto",
],
visibility = ["//visibility:public"],
)
"""
)
I'd be very interested in finding an easier way to get this done.
-Saurabh.