def _dirty_deps(t, depth, fromdir): debug('%s?%s\n' % (depth, t)) stamptime = state.stamped(t, fromdir) if stamptime == None: debug('%s-- DIRTY (no stamp)\n' % depth) return True try: realtime = os.stat(os.path.join(fromdir or '', 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, fromdir): if mode == 'c': if os.path.exists(name): debug('%s-- DIRTY (created)\n' % depth) return True elif mode == 'm': if dirty_deps(name, depth + ' ', fromdir=vars.BASE): #debug('%s-- DIRTY (sub)\n' % depth) return True return False
def main(targets, buildfunc): retcode = [0] # a list so that it can be reassigned from done() if vars.SHUFFLE: random.shuffle(targets) locked = [] def done(t, rv): if rv: err('%s: exit code was %r\n' % (t, rv)) retcode[0] = 1 for i in range(len(targets)): t = targets[i] if os.path.exists('%s/all.do' % t): # t is a directory, but it has a default target targets[i] = '%s/all' % t for t in targets: jwack.get_token(t) lock = state.Lock(t) lock.trylock() if not lock.owned: log('%s (locked...)\n' % relpath(t, vars.STARTDIR)) locked.append(t) else: jwack.start_job(t, lock, lambda: buildfunc(t), lambda t,rv: done(t,rv)) while locked or jwack.running(): jwack.wait_all() if locked: t = locked.pop(0) lock = state.Lock(t) while not lock.owned: lock.wait() lock.trylock() assert(lock.owned) relp = relpath(t, vars.STARTDIR) log('%s (...unlocked!)\n' % relp) if state.stamped(t) == None: err('%s: failed in another thread\n' % relp) retcode[0] = 2 lock.unlock() else: jwack.start_job(t, lock, lambda: buildfunc(t), lambda t,rv: done(t,rv)) return retcode[0]