ENH: raise an exception when we detect an error while executing the batch file.
authorcournape <cournape@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 19 Nov 2009 04:59:58 +0000 (04:59 +0000)
committercournape <cournape@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 19 Nov 2009 04:59:58 +0000 (04:59 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@4446 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Tool/MSCommon/vc2.py

index 2d246b2995d27b6a0eb5de559fdd9ae1fdd28158..2b89b70bc9ec0358fd0ea0e95c6c68c798a8d37c 100644 (file)
@@ -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()