The behaviour is what we wanted, but it shouldn't have worked. So fix the bug in redo-ifchange, then change test.do to use 'redo' instead so it continues to do what we want, only for the right reason. (The bug is that 'redo-ifchange dirname', which runs dirname/all.do, didn't result in stamps getting checked correctly.)
61 lines
1.6 KiB
Python
Executable file
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):
|
|
if os.path.exists('%s/.' % t):
|
|
t = '%s/all' % t
|
|
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
|
|
|
|
try:
|
|
realtime = os.stat(t).st_mtime
|
|
except OSError:
|
|
realtime = 0
|
|
|
|
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)
|