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.
This commit is contained in:
Avery Pennarun 2010-11-24 03:06:18 -08:00
commit 60f5446733
6 changed files with 21 additions and 5 deletions

View file

@ -52,7 +52,9 @@ try:
try: try:
targets = sys.argv[1:] targets = sys.argv[1:]
for t in targets: 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) rv = builder.main(targets, should_build)
finally: finally:
jwack.force_return_tokens() jwack.force_return_tokens()

7
t/.gitignore vendored
View file

@ -7,6 +7,7 @@ d
test.args test.args
test2.args test2.args
/passfail /passfail
mode1 /mode1
makedir /makedir
makedir.log /makedir.log
/chdir1

1
t/chdir1.do Normal file
View file

@ -0,0 +1 @@
echo hello

3
t/chdir2.do Normal file
View file

@ -0,0 +1,3 @@
# make sure redo-ifchange records the dependency correctly if we chdir
cd ..
redo-ifchange t/chdir1

9
t/chdirtest.do Normal file
View file

@ -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

View file

@ -1,4 +1,4 @@
redo example/clean curse/clean deps/clean "space dir/clean" 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 -f hello [by]ellow *.o *~ .*~ CC LD passfail
rm -rf makedir rm -rf makedir