Commit b3c2ec70 authored by Fahrzin Hemmati's avatar Fahrzin Hemmati

Handle multiple outs per input (for plugins)

parent a6501e4a
...@@ -91,8 +91,10 @@ def _proto_gen_impl(ctx): ...@@ -91,8 +91,10 @@ def _proto_gen_impl(ctx):
), ),
) )
for src, out in zip(srcs, ctx.outputs.outs): for src in srcs:
args = [] args = []
src_name = src.basename[:-len(".proto")]
outs = [out for out in ctx.outputs.outs if src_name in out.basename]
in_gen_dir = src.root.path == gen_dir.rstrip('/') in_gen_dir = src.root.path == gen_dir.rstrip('/')
if in_gen_dir: if in_gen_dir:
...@@ -126,27 +128,28 @@ def _proto_gen_impl(ctx): ...@@ -126,27 +128,28 @@ def _proto_gen_impl(ctx):
args += ["--%s_out=%s" % (lang, outdir)] args += ["--%s_out=%s" % (lang, outdir)]
inputs += [plugin] inputs += [plugin]
if in_gen_dir: for out in outs:
orig_command = " ".join( if in_gen_dir:
["$(realpath %s)" % ctx.executable.protoc.path] + args + orig_command = " ".join(
import_flags_real + ["-I.", src.basename]) ["$(realpath %s)" % ctx.executable.protoc.path] + args +
command = ";".join([ import_flags_real + ["-I.", src.basename])
'CMD="%s"' % orig_command, command = ";".join([
"cd %s" % src.dirname, 'CMD="%s"' % orig_command,
"${CMD}", "cd %s" % src.dirname,
"cd -", "${CMD}",
"mv %s/%s %s" % (gen_dir, out.basename, out.path) "cd -",
]) "mv %s/%s %s" % (gen_dir, out.basename, out.path)
else: ])
command = " ".join( else:
[ctx.executable.protoc.path] + args + import_flags + [src.path]) command = " ".join(
ctx.action( [ctx.executable.protoc.path] + args + import_flags + [src.path])
inputs=inputs + [ctx.executable.protoc], ctx.action(
outputs=[out], inputs=inputs + [ctx.executable.protoc],
command=command, outputs=[out],
mnemonic="ProtoCompile", command=command,
use_default_shell_env=True, mnemonic="ProtoCompile",
) use_default_shell_env=True,
)
return struct( return struct(
proto=struct( proto=struct(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment