diff options
author | Fahrzin Hemmati <fahhem@appliedintuition.com> | 2018-03-14 17:49:04 -0700 |
---|---|---|
committer | Fahrzin Hemmati <fahhem@appliedintuition.com> | 2018-05-07 15:40:31 -0700 |
commit | b3c2ec70733e3945f0c13b8aa21b9060445b3a1f (patch) | |
tree | d391119f035fe012e0ff57bffd4eba6fb50dd6ca /protobuf.bzl | |
parent | a6501e4a2b491ad6d27a8e47e93b74e3230a5406 (diff) | |
download | protobuf-b3c2ec70733e3945f0c13b8aa21b9060445b3a1f.tar.gz protobuf-b3c2ec70733e3945f0c13b8aa21b9060445b3a1f.tar.bz2 protobuf-b3c2ec70733e3945f0c13b8aa21b9060445b3a1f.zip |
Handle multiple outs per input (for plugins)
Diffstat (limited to 'protobuf.bzl')
-rw-r--r-- | protobuf.bzl | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/protobuf.bzl b/protobuf.bzl index 98e18108..5c4a24d7 100644 --- a/protobuf.bzl +++ b/protobuf.bzl @@ -91,8 +91,10 @@ def _proto_gen_impl(ctx): ), ) - for src, out in zip(srcs, ctx.outputs.outs): + for src in srcs: 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('/') if in_gen_dir: @@ -126,27 +128,28 @@ def _proto_gen_impl(ctx): args += ["--%s_out=%s" % (lang, outdir)] inputs += [plugin] - if in_gen_dir: - orig_command = " ".join( - ["$(realpath %s)" % ctx.executable.protoc.path] + args + - import_flags_real + ["-I.", src.basename]) - command = ";".join([ - 'CMD="%s"' % orig_command, - "cd %s" % src.dirname, - "${CMD}", - "cd -", - "mv %s/%s %s" % (gen_dir, out.basename, out.path) - ]) - else: - command = " ".join( - [ctx.executable.protoc.path] + args + import_flags + [src.path]) - ctx.action( - inputs=inputs + [ctx.executable.protoc], - outputs=[out], - command=command, - mnemonic="ProtoCompile", - use_default_shell_env=True, - ) + for out in outs: + if in_gen_dir: + orig_command = " ".join( + ["$(realpath %s)" % ctx.executable.protoc.path] + args + + import_flags_real + ["-I.", src.basename]) + command = ";".join([ + 'CMD="%s"' % orig_command, + "cd %s" % src.dirname, + "${CMD}", + "cd -", + "mv %s/%s %s" % (gen_dir, out.basename, out.path) + ]) + else: + command = " ".join( + [ctx.executable.protoc.path] + args + import_flags + [src.path]) + ctx.action( + inputs=inputs + [ctx.executable.protoc], + outputs=[out], + command=command, + mnemonic="ProtoCompile", + use_default_shell_env=True, + ) return struct( proto=struct( |