Skip to content
Snippets Groups Projects
Commit c872a993 authored by Makarand Dharmapurikar's avatar Makarand Dharmapurikar
Browse files

.proto and BUILD files can now in differnt dirs

parent dd109da2
No related branches found
No related tags found
No related merge requests found
...@@ -9,16 +9,16 @@ def generate_cc_impl(ctx): ...@@ -9,16 +9,16 @@ def generate_cc_impl(ctx):
protos = [f for src in ctx.attr.srcs for f in src.proto.direct_sources] 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] includes = [f for src in ctx.attr.srcs for f in src.proto.transitive_imports]
outs = [] 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: if ctx.executable.plugin:
outs += [proto.basename[:-len(".proto")] + ".grpc.pb.h" for proto in protos] outs += [proto.path[label_len:-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.cc" for proto in protos]
else: else:
outs += [proto.basename[:-len(".proto")] + ".pb.h" for proto in protos] outs += [proto.path[label_len:-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.cc" for proto in protos]
out_files = [ctx.new_file(out) for out in outs] out_files = [ctx.new_file(out) for out in outs]
# The following should be replaced with ctx.configuration.buildout dir_out = str(ctx.genfiles_dir.path)
# whenever this is added to Skylark.
dir_out = out_files[0].dirname[:-len(protos[0].dirname)]
arguments = [] arguments = []
if ctx.executable.plugin: if ctx.executable.plugin:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment