diff --git a/builder.py b/builder.py index febfeb6..259faac 100644 --- a/builder.py +++ b/builder.py @@ -64,18 +64,18 @@ class BuildJob: # important to prevent infinite recursion. For example, a rule # called default.c.do could be used to try to produce hello.c, # which is undesirable since hello.c existed already. - state.stamp(t) + state.stamp_and_maybe_built(t) return self._after2(0) state.start(t) (dofile, basename, ext) = _find_do_file(t) if not dofile: if os.path.exists(t): - state.stamp(t) + state.stamp_and_maybe_built(t) return self._after2(0) else: err('no rule to make %r\n' % t) return self._after2(1) - state.stamp(dofile) + state.stamp_and_maybe_built(dofile) unlink(tmpname) ffd = os.open(tmpname, os.O_CREAT|os.O_RDWR|os.O_EXCL, 0666) close_on_exec(ffd, True) diff --git a/state.py b/state.py index c17fe7a..64e538f 100644 --- a/state.py +++ b/state.py @@ -127,6 +127,14 @@ def isbuilt(t): 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): try: open(_sname('mark', t), 'w').close() diff --git a/t/deps/.gitignore b/t/deps/.gitignore index 4dfb618..56f4914 100644 --- a/t/deps/.gitignore +++ b/t/deps/.gitignore @@ -3,4 +3,5 @@ t2.count overwrite overwrite[123] genfile2 -genfile.log \ No newline at end of file +genfile.log +static.log diff --git a/t/deps/clean.do b/t/deps/clean.do index a1d9f1e..5ddd8a9 100644 --- a/t/deps/clean.do +++ b/t/deps/clean.do @@ -1,4 +1,3 @@ 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 diff --git a/t/deps/doublestatic.do b/t/deps/doublestatic.do new file mode 100644 index 0000000..39493c8 --- /dev/null +++ b/t/deps/doublestatic.do @@ -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 diff --git a/t/deps/static2.do b/t/deps/static2.do new file mode 100644 index 0000000..7b739f8 --- /dev/null +++ b/t/deps/static2.do @@ -0,0 +1,2 @@ +redo-ifchange static.in +echo $$ >>static.log diff --git a/t/deps/test.do b/t/deps/test.do index 2815253..8b14385 100644 --- a/t/deps/test.do +++ b/t/deps/test.do @@ -1 +1,2 @@ -redo test1 test2 ifchange-fail overwrite gentest basic/test dirtest/test \ No newline at end of file +redo test1 test2 ifchange-fail overwrite gentest doublestatic \ + basic/test dirtest/test \ No newline at end of file