From 68039fbfd001ed096e2d47baaaedf9d8f1583cef Mon Sep 17 00:00:00 2001 From: cournape Date: Thu, 19 Nov 2009 04:59:58 +0000 Subject: [PATCH] ENH: raise an exception when we detect an error while executing the batch file. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4446 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Tool/MSCommon/vc2.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/MSCommon/vc2.py b/src/engine/SCons/Tool/MSCommon/vc2.py index 2d246b29..2b89b70b 100644 --- a/src/engine/SCons/Tool/MSCommon/vc2.py +++ b/src/engine/SCons/Tool/MSCommon/vc2.py @@ -35,6 +35,9 @@ import common debug = common.debug +class BatchFileExecutionError(Exception): + pass + # Dict to 'canonalize' the arch _ARCH_TO_CANONICAL = { "x86": "x86", @@ -142,6 +145,12 @@ def get_installed_vcs(): def script_env(script, args=None): stdout = common.get_output(script, args) + # Stupid batch files do not set return code: we take a look at the + # beginning of the output for an error message instead + olines = stdout.splitlines() + if olines[0].startswith("The specified configuration type is missing"): + raise BatchFileExecutionError("\n".join(olines[:2])) + return common.parse_output(stdout) def get_default_version(env): @@ -196,7 +205,16 @@ def msvc_setup_env(env): host_target = (host_platform, target_platform) arg = _HOST_TARGET_ARCH_TO_BAT_ARCH[host_target] debug('use_script 2 %s, args:%s\n' % (repr(script), arg)) - d = script_env(script, args=arg) + try: + d = script_env(script, args=arg) + except BatchFileExecutionError, e: + # XXX: find out why warnings do not work here + print "+++++++++++++++++++++++++++++" + msg = "Error while executing %s with args %s (error was %s)" % \ + (script, arg, str(e)) + print msg + print "+++++++++++++++++++++++++++++" + return None else: debug('msvc.get_default_env()\n') d = msvc.get_default_env() -- 2.26.2