Move 'redo --ifchange' into 'redo-ifchange' to match djb's style.
It does simplify the logic of both redo.py and redo-ifchange.py, I suppose.
This commit is contained in:
parent
63c596ac61
commit
c57de820fb
12 changed files with 103 additions and 87 deletions
61
redo-ifchange.py
Executable file
61
redo-ifchange.py
Executable file
|
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/python
|
||||
import sys, os
|
||||
import vars
|
||||
from helpers import *
|
||||
from log import *
|
||||
from libdo import *
|
||||
|
||||
|
||||
def _dirty_deps(t, depth):
|
||||
debug('%s?%s\n' % (depth, t))
|
||||
if not os.path.exists(sname('stamp', t)):
|
||||
debug('%s-- DIRTY (no stamp)\n' % depth)
|
||||
return True
|
||||
|
||||
stamptime = os.stat(sname('stamp', t)).st_mtime
|
||||
try:
|
||||
realtime = os.stat(t).st_mtime
|
||||
except OSError:
|
||||
realtime = 0
|
||||
|
||||
if stamptime != realtime:
|
||||
debug('%s-- DIRTY (mtime)\n' % depth)
|
||||
return True
|
||||
|
||||
for sub in open(sname('dep', t)).readlines():
|
||||
assert(sub[0] in ('c','m'))
|
||||
assert(sub[1] == ' ')
|
||||
assert(sub[-1] == '\n')
|
||||
mode = sub[0]
|
||||
name = sub[2:-1]
|
||||
if mode == 'c':
|
||||
if os.path.exists(name):
|
||||
debug('%s-- DIRTY (created)\n' % depth)
|
||||
return True
|
||||
elif mode == 'm':
|
||||
if dirty_deps(name, depth + ' '):
|
||||
#debug('%s-- DIRTY (sub)\n' % depth)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def dirty_deps(t, depth):
|
||||
if _dirty_deps(t, depth):
|
||||
unlink(sname('stamp', t)) # short circuit future checks
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
if not vars.TARGET:
|
||||
sys.stderr.write('redo-ifchange: error: must be run from inside a .do\n')
|
||||
sys.exit(1)
|
||||
|
||||
want_build = []
|
||||
for t in sys.argv[1:]:
|
||||
mkdirp('%s/.redo' % vars.BASE)
|
||||
add_dep(vars.TARGET, 'm', t)
|
||||
if dirty_deps(t, depth = ''):
|
||||
want_build.append(t)
|
||||
|
||||
if want_build:
|
||||
os.execvp('redo', ['redo', '--'] + want_build)
|
||||
Loading…
Add table
Add a link
Reference in a new issue