Fix more trouble with .do scripts that cd to other directories.

The interaction of REDO_STARTDIR, REDO_PWD, and getcwd() are pretty
complicated.  In this case, we accidentally assumed that the current
instance of redo was running with getcwd() == REDO_STARTDIR+REDO_PWD, and so
the new target was REDO_STARTDIR+REDO_PWD+t, but this isn't the case if the
current .do script did chdir().

The correct answer is REDO_STARTDIR+getcwd()+t.
This commit is contained in:
Avery Pennarun 2010-11-25 06:35:22 -08:00
commit c29de89051
4 changed files with 22 additions and 12 deletions

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
import sys, os, errno
import vars, state, builder, jwack
from helpers import debug, err, mkdirp, unlink
from helpers import debug, debug2, err, mkdirp, unlink
def dirty_deps(t, depth):
@ -49,12 +49,13 @@ def should_build(t):
rv = 202
try:
me = os.path.join(vars.STARTDIR,
os.path.join(vars.PWD, vars.TARGET))
debug2('TARGET: %r %r %r\n' % (vars.STARTDIR, vars.PWD, vars.TARGET))
try:
targets = sys.argv[1:]
for t in targets:
state.add_dep(os.path.join(vars.STARTDIR,
os.path.join(vars.PWD, vars.TARGET)),
'm', t)
state.add_dep(me, 'm', t)
rv = builder.main(targets, should_build)
finally:
jwack.force_return_tokens()