If a depends on b depends on c, and c is dirty but b uses redo-stamp checksums, then 'redo-ifchange a' is indeterminate: we won't know if we need to run a.do unless we first build b, but the script that *normally* runs 'redo-ifchange b' is a.do, and we don't want to run that yet, because we don't know for sure if b is dirty, and we shouldn't build a unless one of its dependencies is dirty. Eek! Luckily, there's a safe solution. If we *know* a is dirty - eg. because a.do or one of its children has definitely changed - then we can just run a.do immediately and there's no problem, even if b is indeterminate, because we were going to run a.do anyhow. If a's dependencies are *not* definitely dirty, and all we have is indeterminate ones like b, then that means a's build process *hasn't changed*, which means its tree of dependencies still includes b, which means we can deduce that if we *did* run a.do, it would end up running b.do. Since we know that anyhow, we can safely just run b.do, which will either b.set_checked() or b.set_changed(). Once that's done, we can re-parse a's dependencies and this time conclusively tell if it needs to be redone or not. Even if it does, b is already up-to-date, so the 'redo-ifchange b' line in a.do will be fast. ...now take all the above and do it recursively to handle nested dependencies, etc, and you're done.
27 lines
1 KiB
Python
27 lines
1 KiB
Python
import os
|
|
import atoi
|
|
|
|
if not os.environ.get('REDO'):
|
|
import sys
|
|
sys.stderr.write('%s: error: must be run from inside a .do\n'
|
|
% sys.argv[0])
|
|
sys.exit(100)
|
|
|
|
PWD = os.environ.get('REDO_PWD', '')
|
|
TARGET = os.environ.get('REDO_TARGET', '')
|
|
DEPTH = os.environ.get('REDO_DEPTH', '')
|
|
DEBUG = atoi.atoi(os.environ.get('REDO_DEBUG', ''))
|
|
DEBUG_LOCKS = os.environ.get('REDO_DEBUG_LOCKS', '') and 1 or 0
|
|
DEBUG_PIDS = os.environ.get('REDO_DEBUG_PIDS', '') and 1 or 0
|
|
VERBOSE = os.environ.get('REDO_VERBOSE', '') and 1 or 0
|
|
XTRACE = os.environ.get('REDO_XTRACE', '') and 1 or 0
|
|
KEEP_GOING = os.environ.get('REDO_KEEP_GOING', '') and 1 or 0
|
|
SHUFFLE = os.environ.get('REDO_SHUFFLE', '') and 1 or 0
|
|
STARTDIR = os.environ['REDO_STARTDIR']
|
|
RUNID = atoi.atoi(os.environ.get('REDO_RUNID')) or None
|
|
BASE = os.environ['REDO_BASE']
|
|
while BASE and BASE.endswith('/'):
|
|
BASE = BASE[:-1]
|
|
|
|
UNLOCKED = os.environ.get('REDO_UNLOCKED', '') and 1 or 0
|
|
os.environ['REDO_UNLOCKED'] = '' # not inheritable by subprocesses
|