From 60f54467337135590d3fa7d9148f96e56c19638a Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Wed, 24 Nov 2010 03:06:18 -0800 Subject: [PATCH] Correctly handle dependencies for "cd somewhere; redo-ifchange somefile" We would build 'somefile' correctly the first time, but we wouldn't attach the dependency on somefile to the right $TARGET, so our target would not auto-rebuild in the future based on somefile. --- redo-ifchange.py | 4 +++- t/.gitignore | 7 ++++--- t/chdir1.do | 1 + t/chdir2.do | 3 +++ t/chdirtest.do | 9 +++++++++ t/clean.do | 2 +- 6 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 t/chdir1.do create mode 100644 t/chdir2.do create mode 100644 t/chdirtest.do diff --git a/redo-ifchange.py b/redo-ifchange.py index 4d2b51d..de73201 100755 --- a/redo-ifchange.py +++ b/redo-ifchange.py @@ -52,7 +52,9 @@ try: try: targets = sys.argv[1:] for t in targets: - state.add_dep(vars.TARGET, 'm', t) + state.add_dep(os.path.join(vars.STARTDIR, + os.path.join(vars.PWD, vars.TARGET)), + 'm', t) rv = builder.main(targets, should_build) finally: jwack.force_return_tokens() diff --git a/t/.gitignore b/t/.gitignore index 3989fa7..a746a34 100644 --- a/t/.gitignore +++ b/t/.gitignore @@ -7,6 +7,7 @@ d test.args test2.args /passfail -mode1 -makedir -makedir.log \ No newline at end of file +/mode1 +/makedir +/makedir.log +/chdir1 diff --git a/t/chdir1.do b/t/chdir1.do new file mode 100644 index 0000000..2f08be9 --- /dev/null +++ b/t/chdir1.do @@ -0,0 +1 @@ +echo hello diff --git a/t/chdir2.do b/t/chdir2.do new file mode 100644 index 0000000..d32f31a --- /dev/null +++ b/t/chdir2.do @@ -0,0 +1,3 @@ +# make sure redo-ifchange records the dependency correctly if we chdir +cd .. +redo-ifchange t/chdir1 diff --git a/t/chdirtest.do b/t/chdirtest.do new file mode 100644 index 0000000..5428534 --- /dev/null +++ b/t/chdirtest.do @@ -0,0 +1,9 @@ +redo chdir1 +redo chdir2 +rm -f chdir1 +. ./flush-cache.sh + +# chdir2 sets its dependency on chdir1 in an odd way, so this might fail if +# redo doesn't catch it +redo-ifchange chdir2 +[ -e chdir1 ] || exit 77 diff --git a/t/clean.do b/t/clean.do index e4f5666..8037f29 100644 --- a/t/clean.do +++ b/t/clean.do @@ -1,4 +1,4 @@ redo example/clean curse/clean deps/clean "space dir/clean" -rm -f c c.c c.c.c c.c.c.b c.c.c.b.b d mode1 makedir.log +rm -f c c.c c.c.c c.c.c.b c.c.c.b.b d mode1 makedir.log chdir1 rm -f hello [by]ellow *.o *~ .*~ CC LD passfail rm -rf makedir \ No newline at end of file