If we can't find a .do file for a target, mark it as not is_generated.

This allows files to transition from generated to not-generated if the .do
file is ever removed (ie. the user is changing things and the file is now a
source file, not a target).
This commit is contained in:
Avery Pennarun 2010-12-06 03:12:53 -08:00
commit 51bbdc6c5a
2 changed files with 17 additions and 7 deletions

View file

@ -58,19 +58,23 @@ class BuildJob:
# target doesn't need to be built; skip the whole task # target doesn't need to be built; skip the whole task
return self._after2(0) return self._after2(0)
if (os.path.exists(t) and not os.path.exists(t + '/.') if (os.path.exists(t) and not os.path.exists(t + '/.')
and not state.is_generated(t) and not state.is_generated(t)):
and not os.path.exists('%s.do' % t)): # an existing source file that was not generated by us.
# an existing source file that is not marked as a generated file. # This step is mentioned by djb in his notes.
# This step is mentioned by djb in his notes. It turns out to be # For example, a rule called default.c.do could be used to try
# important to prevent infinite recursion. For example, a rule # to produce hello.c, but we don't want that to happen if
# called default.c.do could be used to try to produce hello.c, # hello.c was created by the end user.
# which is undesirable since hello.c existed already. # FIXME: always refuse to redo any file that was modified outside
# of redo? That would make it easy for someone to override a
# file temporarily, and could be undone by deleting the file.
state.unmark_as_generated(t)
state.stamp_and_maybe_built(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.unmark_as_generated(t)
state.stamp_and_maybe_built(t) state.stamp_and_maybe_built(t)
return self._after2(0) return self._after2(0)
else: else:

View file

@ -97,6 +97,12 @@ def stamp(t):
def unstamp(t): def unstamp(t):
unlink(_stampname(t)) unlink(_stampname(t))
unlink(_sname('dep', t))
def unmark_as_generated(t):
unstamp(t)
unlink(_sname('gen', t))
def stamped(t): def stamped(t):