From b937e62d890d8076391252555ed891bf8d4b5066 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Sun, 21 Nov 2010 07:10:48 -0800 Subject: [PATCH] Add a new -k (--keep-going) option, like make has. Previously, the default was to *always* keep going, which is actually not usually what you want. Now we actually exit correctly after an error. Of course you still might have multiple errors before existing if you were building in parallel. --- builder.py | 6 +++++- redo.py | 7 +++++-- vars.py | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/builder.py b/builder.py index 15ec1fa..c099484 100644 --- a/builder.py +++ b/builder.py @@ -116,7 +116,7 @@ def main(targets, buildfunc): def done(t, rv): if rv: - err('%s: exit code was %r\n' % (t, rv)) + #err('%s: exit code was %r\n' % (t, rv)) retcode[0] = 1 for i in range(len(targets)): @@ -127,6 +127,8 @@ def main(targets, buildfunc): for t in targets: jwack.get_token(t) + if retcode[0] and not vars.KEEP_GOING: + break lock = state.Lock(t) lock.trylock() if not lock.owned: @@ -139,6 +141,8 @@ def main(targets, buildfunc): while locked or jwack.running(): jwack.wait_all() + if retcode[0] and not vars.KEEP_GOING: + break if locked: t = locked.pop(0) lock = state.Lock(t) diff --git a/redo.py b/redo.py index b13df5a..4b359f8 100755 --- a/redo.py +++ b/redo.py @@ -9,6 +9,7 @@ j,jobs= maximum number of jobs to build at once d,debug print dependency checks as they happen v,verbose print commands as they are read from .do files (variables intact) x,xtrace print commands as they are executed (variables expanded) +k,keep-going keep going as long as possible even if some targets fail shuffle randomize the build order to find dependency bugs debug-locks print messages about file locking (useful for debugging) """ @@ -23,6 +24,8 @@ if opt.verbose: os.environ['REDO_VERBOSE'] = '1' if opt.xtrace: os.environ['REDO_XTRACE'] = '1' +if opt.keep_going: + os.environ['REDO_KEEP_GOING'] = '1' if opt.shuffle: os.environ['REDO_SHUFFLE'] = '1' if opt.debug_locks: @@ -67,8 +70,8 @@ try: retcode = builder.main(targets, builder.build) finally: jwack.force_return_tokens() - if retcode: - err('exiting: %d\n' % retcode) + #if retcode: + # err('exiting: %d\n' % retcode) sys.exit(retcode) except KeyboardInterrupt: sys.exit(200) diff --git a/vars.py b/vars.py index 191a0da..9b04c31 100644 --- a/vars.py +++ b/vars.py @@ -8,6 +8,7 @@ DEBUG = atoi.atoi(os.environ.get('REDO_DEBUG', '')) DEBUG_LOCKS = os.environ.get('REDO_DEBUG_LOCKS', '') 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'] BASE = os.environ['REDO_BASE']