apenwarr-redo/redo-ifchange.py
Avery Pennarun 984ad747f8 Remove special case for "dirname" -> "dirname/all"
It actually decreases readability of the .do files - by not making it
explicit when you're going into a subdir.

Plus it adds ambiguity: what if there's a dirname.do *and* a dirname/all?
We could resolve the ambiguity if we wanted, but that adds more code, while
taking out this special case makes *less* code and improves readability.
I think it's the right way to go.
2010-11-24 02:48:27 -08:00

61 lines
1.6 KiB
Python
Executable file

#!/usr/bin/python
import sys, os, errno
import vars, state, builder, jwack
from helpers import debug, err, mkdirp, unlink
def dirty_deps(t, depth):
try:
st = os.stat(t)
realtime = st.st_mtime
except OSError:
st = None
realtime = 0
debug('%s?%s\n' % (depth, t))
if state.isbuilt(t):
debug('%s-- DIRTY (built)\n' % depth)
return True # has already been built during this session
if state.ismarked(t):
debug('%s-- CLEAN (marked)\n' % depth)
return False # has already been checked during this session
stamptime = state.stamped(t)
if stamptime == None:
debug('%s-- DIRTY (no stamp)\n' % depth)
return True
if stamptime != realtime:
debug('%s-- DIRTY (mtime)\n' % depth)
return True
for mode,name in state.deps(t):
if mode == 'c':
if os.path.exists(name):
debug('%s-- DIRTY (created)\n' % depth)
return True
elif mode == 'm':
if dirty_deps(os.path.join(vars.BASE, name), depth + ' '):
debug('%s-- DIRTY (sub)\n' % depth)
state.unstamp(t) # optimization for future callers
return True
state.mark(t)
return False
def should_build(t):
return not state.isbuilt(t) and dirty_deps(t, depth = '')
rv = 202
try:
try:
targets = sys.argv[1:]
for t in targets:
state.add_dep(vars.TARGET, 'm', t)
rv = builder.main(targets, should_build)
finally:
jwack.force_return_tokens()
except KeyboardInterrupt:
sys.exit(200)
sys.exit(rv)