aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/build_rules
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2016-04-12 13:37:58 +0000
committerGravatar Lukacs Berki <lberki@google.com>2016-04-13 08:08:35 +0000
commitc6c516dda8083caa42a60db7b82fcf52647a8cb3 (patch)
tree2650e9ba37f1a7b462d03cb902d3217f62233cc8 /tools/build_rules
parent5215d1e804a830e256a7dc23c44f737a332495f4 (diff)
Make the genproto rules of Bazel usable from other repositories.
This is mainly so that Dash can be fixed. It's not the optimal solution because then Dash will pull in the whole Bazel repository for a tiny little part of it, though. The optimal solution would be to make Bazel use WORKSPACE dependencies and then factor it out to a separate repository, but this will be good enough to unbreak Dash for the time being. Progress toward fixing https://github.com/bazelbuild/dash/issues/12 . -- MOS_MIGRATED_REVID=119633183
Diffstat (limited to 'tools/build_rules')
-rw-r--r--tools/build_rules/genproto.bzl22
1 files changed, 13 insertions, 9 deletions
diff --git a/tools/build_rules/genproto.bzl b/tools/build_rules/genproto.bzl
index bc76cd1ac3..1da0447f13 100644
--- a/tools/build_rules/genproto.bzl
+++ b/tools/build_rules/genproto.bzl
@@ -51,7 +51,7 @@ gensrcjar = rule(
single_file = True,
),
"_gensrcjar": attr.label(
- default = Label("//tools/build_rules:gensrcjar"),
+ default = Label(str(Label("//tools/build_rules:gensrcjar"))),
executable = True,
),
# TODO(bazel-team): this should be a hidden attribute with a default
@@ -82,14 +82,15 @@ gensrcjar = rule(
def cc_grpc_library(name, src):
basename = src[:-len(".proto")]
-
+ protoc_label = str(Label("//third_party/protobuf:protoc"))
+ cpp_plugin_label = str(Label("//third_party/grpc:cpp_plugin"))
native.genrule(
name = name + "_codegen",
srcs = [src],
- tools = ["//third_party/protobuf:protoc", "//third_party/grpc:cpp_plugin"],
+ tools = [protoc_label, cpp_plugin_label],
cmd = "\\\n".join([
- "$(location //third_party/protobuf:protoc)",
- " --plugin=protoc-gen-grpc=$(location //third_party/grpc:cpp_plugin)",
+ "$(location " + protoc_label + ")",
+ " --plugin=protoc-gen-grpc=$(location " + cpp_plugin_label + ")",
" --cpp_out=$(GENDIR)",
" --grpc_out=$(GENDIR)",
" $(location " + src + ")"]),
@@ -99,19 +100,22 @@ def cc_grpc_library(name, src):
name = name,
srcs = [basename + ".grpc.pb.cc", basename + ".pb.cc"],
hdrs = [basename + ".grpc.pb.h", basename + ".pb.h"],
- deps = ["//third_party/grpc:grpc++"],
+ deps = [str(Label("//third_party/grpc:grpc++"))],
includes = ["."])
# TODO(bazel-team): support proto => proto dependencies too
def java_proto_library(name, src, use_grpc_plugin=False):
grpc_java_plugin = None
if use_grpc_plugin:
- grpc_java_plugin = "//third_party/grpc:grpc-java-plugin"
+ grpc_java_plugin = str(Label("//third_party/grpc:grpc-java-plugin"))
gensrcjar(name=name + "_srcjar", src=src, grpc_java_plugin=grpc_java_plugin)
- deps = ["//third_party/protobuf"]
+ deps = [str(Label("//third_party/protobuf"))]
if use_grpc_plugin:
- deps += ["//third_party/grpc:grpc-jar", "//third_party:guava"]
+ deps += [
+ str(Label("//third_party/grpc:grpc-jar")),
+ str(Label("//third_party:guava")),
+ ]
native.java_library(
name=name,
srcs=[name + "_srcjar"],