builder.py: correctly set $3 to include the subdir path.
If we're using a .do file from a parent directory, we should set $3 using the same path prefix as $1. We were previously using just the basename, which mostly works (since we would rename it to $1$2 eventually anyway) but is not quite right, and you can't safely rename files across filesystems, so it could theoretically cause problems. Also improved t/defaults-nested to test for this behaviour. Reported by Eric Kow.
This commit is contained in:
parent
f3ae4e4e00
commit
c077d77285
3 changed files with 15 additions and 14 deletions
16
builder.py
16
builder.py
|
|
@ -15,7 +15,8 @@ def _default_do_files(filename):
|
||||||
|
|
||||||
def _possible_do_files(t):
|
def _possible_do_files(t):
|
||||||
dirname,filename = os.path.split(t)
|
dirname,filename = os.path.split(t)
|
||||||
yield os.path.join(vars.BASE, dirname), "%s.do" % filename, filename, ''
|
yield (os.path.join(vars.BASE, dirname), "%s.do" % filename,
|
||||||
|
'', filename, '')
|
||||||
|
|
||||||
# It's important to try every possibility in a directory before resorting
|
# It's important to try every possibility in a directory before resorting
|
||||||
# to a parent directory. Think about nested projects: I don't want
|
# to a parent directory. Think about nested projects: I don't want
|
||||||
|
|
@ -30,19 +31,20 @@ def _possible_do_files(t):
|
||||||
basedir = join('/', dirbits[:i])
|
basedir = join('/', dirbits[:i])
|
||||||
subdir = join('/', dirbits[i:])
|
subdir = join('/', dirbits[i:])
|
||||||
for dofile,basename,ext in _default_do_files(filename):
|
for dofile,basename,ext in _default_do_files(filename):
|
||||||
yield basedir, dofile, os.path.join(subdir, basename), ext
|
yield (basedir, dofile,
|
||||||
|
subdir, os.path.join(subdir, basename), ext)
|
||||||
|
|
||||||
|
|
||||||
def _find_do_file(f):
|
def _find_do_file(f):
|
||||||
for dodir,dofile,basename,ext in _possible_do_files(f.name):
|
for dodir,dofile,basedir,basename,ext in _possible_do_files(f.name):
|
||||||
dopath = os.path.join(dodir, dofile)
|
dopath = os.path.join(dodir, dofile)
|
||||||
debug2('%s: %s:%s ?\n' % (f.name, dodir, dofile))
|
debug2('%s: %s:%s ?\n' % (f.name, dodir, dofile))
|
||||||
if os.path.exists(dopath):
|
if os.path.exists(dopath):
|
||||||
f.add_dep('m', dopath)
|
f.add_dep('m', dopath)
|
||||||
return dodir,dofile,basename,ext
|
return dodir,dofile,basedir,basename,ext
|
||||||
else:
|
else:
|
||||||
f.add_dep('c', dopath)
|
f.add_dep('c', dopath)
|
||||||
return None,None,None,None
|
return None,None,None,None,None
|
||||||
|
|
||||||
|
|
||||||
def _nice(t):
|
def _nice(t):
|
||||||
|
|
@ -120,7 +122,7 @@ class BuildJob:
|
||||||
sf.save()
|
sf.save()
|
||||||
return self._after2(0)
|
return self._after2(0)
|
||||||
sf.zap_deps1()
|
sf.zap_deps1()
|
||||||
(dodir, dofile, basename, ext) = _find_do_file(sf)
|
(dodir, dofile, basedir, basename, ext) = _find_do_file(sf)
|
||||||
if not dofile:
|
if not dofile:
|
||||||
if os.path.exists(t):
|
if os.path.exists(t):
|
||||||
sf.set_static()
|
sf.set_static()
|
||||||
|
|
@ -139,7 +141,7 @@ class BuildJob:
|
||||||
dofile,
|
dofile,
|
||||||
basename, # target name (no extension)
|
basename, # target name (no extension)
|
||||||
ext, # extension (if any), including leading dot
|
ext, # extension (if any), including leading dot
|
||||||
os.path.basename(self.tmpname2) # randomized output file name
|
os.path.join(basedir, os.path.basename(self.tmpname2)) # temp output file name
|
||||||
]
|
]
|
||||||
if vars.VERBOSE: argv[1] += 'v'
|
if vars.VERBOSE: argv[1] += 'v'
|
||||||
if vars.XTRACE: argv[1] += 'x'
|
if vars.XTRACE: argv[1] += 'x'
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
echo root $1 $2
|
echo root $1 $2 "$(dirname $3)"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,19 +15,19 @@ check()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check file.x.y.z "root file.x.y.z"
|
check file.x.y.z "root file.x.y.z ."
|
||||||
check file.z "root file.z"
|
check file.z "root file.z ."
|
||||||
check file "root file"
|
check file "root file ."
|
||||||
|
|
||||||
check a/file.x.y.z "default.x.y.z file .x.y.z"
|
check a/file.x.y.z "default.x.y.z file .x.y.z"
|
||||||
check a/file.y.z "default.z file.y .z"
|
check a/file.y.z "default.z file.y .z"
|
||||||
check a/file.z "default.z file .z"
|
check a/file.z "default.z file .z"
|
||||||
check a/file "root a/file"
|
check a/file "root a/file a"
|
||||||
|
|
||||||
check a/b/file.x.y.z "file file.x.y.z"
|
check a/b/file.x.y.z "file file.x.y.z"
|
||||||
check a/b/file.y.z "default.y.z file .y.z"
|
check a/b/file.y.z "default.y.z file .y.z"
|
||||||
check a/b/file.z "default.z b/file .z"
|
check a/b/file.z "default.z b/file .z"
|
||||||
check a/b/file "root a/b/file"
|
check a/b/file "root a/b/file a/b"
|
||||||
|
|
||||||
check a/d/file.x.y.z "default file.x.y.z"
|
check a/d/file.x.y.z "default file.x.y.z"
|
||||||
check a/d/file.y.z "default file.y.z"
|
check a/d/file.y.z "default file.y.z"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue