From: Alexander Bokovoy Date: Tue, 3 Apr 2012 08:22:15 +0000 (+0300) Subject: WAF: Add support for stopping processing before end of wscript{_*} X-Git-Tag: ldb-1.1.6~99 X-Git-Url: http://git.samba.org/samba.git/?a=commitdiff_plain;h=dda0531aae70e78e815fda8c594213369e76a847;p=bbaumbach%2Fsamba-autobuild%2F.git WAF: Add support for stopping processing before end of wscript{_*} WAF scripts are written in Python and Python has no simple way to stop program execution other than using exceptions. This change adds WscriptCheckSkipped exception and its handling in core WAF code. When any of wscript{_*} throws WscriptCheckSkipped exception, WAF simply continues to process next wscript in queue rather than breaking build. WscriptCheckSkipped exception can be used to perform early bail out of configuration/build target checks if certain dependency is not available when the default checks are way more numerous than a check for this particular dependency. This is to avoid 'if ...' indenting for large blocks of existing code which also muddens git history for nothing. Signed-off-by: Andreas Schneider --- diff --git a/buildtools/wafadmin/Utils.py b/buildtools/wafadmin/Utils.py index 41dad570ebe..080d9282143 100644 --- a/buildtools/wafadmin/Utils.py +++ b/buildtools/wafadmin/Utils.py @@ -111,6 +111,9 @@ class WscriptError(WafError): return (frame[0], frame[1]) return (None, None) +class WscriptCheckSkipped(WscriptError): + pass + indicator = is_win32 and '\x1b[A\x1b[K%s%s%s\r' or '\x1b[K%s%s%s\r' try: @@ -645,6 +648,8 @@ class Context(object): try: try: exec(compile(txt, file_path, 'exec'), dc) + except WscriptCheckSkipped: + pass except Exception: exc_type, exc_value, tb = sys.exc_info() raise WscriptError("".join(traceback.format_exception(exc_type, exc_value, tb)), base)