Commit 2cfa7612 authored by Fahrzin Hemmati's avatar Fahrzin Hemmati

Fix moving generated files onto themselves

parent 0d68b29a
...@@ -72,7 +72,7 @@ def _proto_gen_impl(ctx): ...@@ -72,7 +72,7 @@ def _proto_gen_impl(ctx):
deps = [] deps = []
deps += ctx.files.srcs deps += ctx.files.srcs
source_dir = _SourceDir(ctx) source_dir = _SourceDir(ctx)
gen_dir = _GenDir(ctx) gen_dir = _GenDir(ctx).rstrip('/')
if source_dir: if source_dir:
import_flags = ["-I" + source_dir, "-I" + gen_dir] import_flags = ["-I" + source_dir, "-I" + gen_dir]
else: else:
...@@ -94,7 +94,7 @@ def _proto_gen_impl(ctx): ...@@ -94,7 +94,7 @@ def _proto_gen_impl(ctx):
for src in srcs: for src in srcs:
args = [] args = []
in_gen_dir = src.root.path == gen_dir.rstrip('/') in_gen_dir = src.root.path == gen_dir
if in_gen_dir: if in_gen_dir:
import_flags_real = [] import_flags_real = []
for f in depset(import_flags): for f in depset(import_flags):
...@@ -148,8 +148,10 @@ def _proto_gen_impl(ctx): ...@@ -148,8 +148,10 @@ def _proto_gen_impl(ctx):
"cd %s" % src.dirname, "cd %s" % src.dirname,
"${CMD}", "${CMD}",
"cd -", "cd -",
"mv %s/%s %s" % (gen_dir, out.basename, out.path)
]) ])
generated_out = '/'.join([gen_dir, out.basename])
if generated_out != out.path:
command += ";mv %s %s" % (generated_out, out.path)
ctx.action( ctx.action(
inputs=inputs + [ctx.executable.protoc], inputs=inputs + [ctx.executable.protoc],
outputs=[out], outputs=[out],
......
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