aboutsummaryrefslogtreecommitdiffhomepage
path: root/bazel
diff options
context:
space:
mode:
authorGravatar Makarand Dharmapurikar <makarandd@google.com>2017-04-17 16:36:00 -0700
committerGravatar Makarand Dharmapurikar <makarandd@google.com>2017-04-17 16:36:00 -0700
commitc872a993e531d7a630459858e1798f18fabd42e0 (patch)
tree815b2c4bf7a30e8387d7e1a317e4e98de2659eb3 /bazel
parentdd109da28038eb7b2b96a5fb6edcb4be33d6e13d (diff)
.proto and BUILD files can now in differnt dirs
Diffstat (limited to 'bazel')
-rw-r--r--bazel/generate_cc.bzl14
1 files changed, 7 insertions, 7 deletions
diff --git a/bazel/generate_cc.bzl b/bazel/generate_cc.bzl
index f3961f0a41..f8fddeb0d5 100644
--- a/bazel/generate_cc.bzl
+++ b/bazel/generate_cc.bzl
@@ -9,16 +9,16 @@ def generate_cc_impl(ctx):
protos = [f for src in ctx.attr.srcs for f in src.proto.direct_sources]
includes = [f for src in ctx.attr.srcs for f in src.proto.transitive_imports]
outs = []
+ # label_len is length of the path from WORKSPACE root to the location of this build file
+ label_len = len(ctx.label.package) + 1
if ctx.executable.plugin:
- outs += [proto.basename[:-len(".proto")] + ".grpc.pb.h" for proto in protos]
- outs += [proto.basename[:-len(".proto")] + ".grpc.pb.cc" for proto in protos]
+ outs += [proto.path[label_len:-len(".proto")] + ".grpc.pb.h" for proto in protos]
+ outs += [proto.path[label_len:-len(".proto")] + ".grpc.pb.cc" for proto in protos]
else:
- outs += [proto.basename[:-len(".proto")] + ".pb.h" for proto in protos]
- outs += [proto.basename[:-len(".proto")] + ".pb.cc" for proto in protos]
+ outs += [proto.path[label_len:-len(".proto")] + ".pb.h" for proto in protos]
+ outs += [proto.path[label_len:-len(".proto")] + ".pb.cc" for proto in protos]
out_files = [ctx.new_file(out) for out in outs]
- # The following should be replaced with ctx.configuration.buildout
- # whenever this is added to Skylark.
- dir_out = out_files[0].dirname[:-len(protos[0].dirname)]
+ dir_out = str(ctx.genfiles_dir.path)
arguments = []
if ctx.executable.plugin: