doublestatic: fix dependencies if two files depend on one non-generated file.

If a and b both depend on c, and c is a static (non-generated) file that has
changed since the last successful build of a and b, we would try to redo
a, but would forget to redo b.  Now it does both.
This commit is contained in:
Avery Pennarun 2010-11-24 04:52:17 -08:00
commit f3413c0f7c
9 changed files with 31 additions and 8 deletions

View file

@ -64,18 +64,18 @@ class BuildJob:
# important to prevent infinite recursion. For example, a rule # important to prevent infinite recursion. For example, a rule
# called default.c.do could be used to try to produce hello.c, # called default.c.do could be used to try to produce hello.c,
# which is undesirable since hello.c existed already. # which is undesirable since hello.c existed already.
state.stamp(t) state.stamp_and_maybe_built(t)
return self._after2(0) return self._after2(0)
state.start(t) state.start(t)
(dofile, basename, ext) = _find_do_file(t) (dofile, basename, ext) = _find_do_file(t)
if not dofile: if not dofile:
if os.path.exists(t): if os.path.exists(t):
state.stamp(t) state.stamp_and_maybe_built(t)
return self._after2(0) return self._after2(0)
else: else:
err('no rule to make %r\n' % t) err('no rule to make %r\n' % t)
return self._after2(1) return self._after2(1)
state.stamp(dofile) state.stamp_and_maybe_built(dofile)
unlink(tmpname) unlink(tmpname)
ffd = os.open(tmpname, os.O_CREAT|os.O_RDWR|os.O_EXCL, 0666) ffd = os.open(tmpname, os.O_CREAT|os.O_RDWR|os.O_EXCL, 0666)
close_on_exec(ffd, True) close_on_exec(ffd, True)

View file

@ -127,6 +127,14 @@ def isbuilt(t):
return True return True
# stamps the given input file, but only considers it to have been "built" if its
# mtime has changed. This is useful for static (non-generated) files.
def stamp_and_maybe_built(t):
if stamped(t) != os.stat(t).st_mtime:
built(t)
stamp(t)
def mark(t): def mark(t):
try: try:
open(_sname('mark', t), 'w').close() open(_sname('mark', t), 'w').close()

3
t/deps/.gitignore vendored
View file

@ -3,4 +3,5 @@ t2.count
overwrite overwrite
overwrite[123] overwrite[123]
genfile2 genfile2
genfile.log genfile.log
static.log

View file

@ -1,4 +1,3 @@
redo basic/clean dirtest/clean redo basic/clean dirtest/clean
rm -f *~ .*~ *.count t1a overwrite overwrite[123] genfile2 genfile.log rm -f *~ .*~ *.count t1a overwrite overwrite[123] \
genfile2 genfile.log static.log

10
t/deps/doublestatic.do Normal file
View file

@ -0,0 +1,10 @@
rm -f static.log
redo static1 static2
touch static.in
. ../flush-cache.sh
redo-ifchange static1 static2
COUNT=$(wc -l <static.log)
[ "$COUNT" = 4 ] || exit 55

0
t/deps/static.in Normal file
View file

2
t/deps/static1.do Normal file
View file

@ -0,0 +1,2 @@
redo-ifchange static.in
echo $$ >>static.log

2
t/deps/static2.do Normal file
View file

@ -0,0 +1,2 @@
redo-ifchange static.in
echo $$ >>static.log

View file

@ -1 +1,2 @@
redo test1 test2 ifchange-fail overwrite gentest basic/test dirtest/test redo test1 test2 ifchange-fail overwrite gentest doublestatic \
basic/test dirtest/test