diff options
author | David Cournapeau <cournape@gmail.com> | 2009-11-19 05:05:37 (GMT) |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2009-11-19 05:05:37 (GMT) |
commit | 6c90fa628f9b28e6eba69edf23df9fe2089a5810 (patch) | |
tree | 634fb90625be6a0e07577a8ec748beb60e0bf235 | |
parent | 8e7ce03a7ee26528433b2125b1f44975a5731eef (diff) | |
download | SCons-6c90fa628f9b28e6eba69edf23df9fe2089a5810.zip SCons-6c90fa628f9b28e6eba69edf23df9fe2089a5810.tar.gz SCons-6c90fa628f9b28e6eba69edf23df9fe2089a5810.tar.bz2 |
ENH: use Gary error checking, but using exception instead of returning error message (thanks Gary).
-rw-r--r-- | src/engine/SCons/Script/Main.py | 1 | ||||
-rw-r--r-- | src/engine/SCons/Tool/MSCommon/vc.py | 44 |
2 files changed, 28 insertions, 17 deletions
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 6aba90f..dd4f519 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -777,6 +777,7 @@ def _main(parser): SCons.Warnings.ReservedVariableWarning, SCons.Warnings.StackSizeWarning, SCons.Warnings.VisualVersionMismatch, + SCons.Warnings.VisualCMissingWarning, ] for warning in default_warnings: diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index a6c5aaf..227d1ff 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -44,7 +44,19 @@ import common debug = common.debug -class BatchFileExecutionError(Exception): +class VisualCException(Exception): + pass + +class UnsupportedVersion(VisualCException): + pass + +class MissingConfiguration(VisualCException): + pass + +class NoVersionFound(VisualCException): + pass + +class BatchFileExecutionError(VisualCException): pass # Dict to 'canonalize' the arch @@ -114,7 +126,7 @@ def find_vc_pdir(msvc_version): hkeys = _VCVER_TO_PRODUCT_DIR[msvc_version] except KeyError: debug("Unknown version of MSVC: %s" % msvc_version) - return None + raise UnsupportedVersion("Unknown version %s" % msvc_version) for key in hkeys: key = root + key @@ -129,13 +141,13 @@ def find_vc_pdir(msvc_version): else: debug('find_vc_dir(): reg says dir is %s, but it does not exist. (ignoring)'\ % comps) - return None + raise MissingConfiguration("registry dir %s not found on the filesystem" % comps) return None def find_batch_file(msvc_version): pdir = find_vc_pdir(msvc_version) if pdir is None: - return None + raise NoVersionFound("No version of Visual Studio found") vernum = float(msvc_version) if 7 <= vernum < 8: @@ -229,14 +241,16 @@ def msvc_setup_env(env): env['MSVS_VERSION'] = version env['MSVS'] = {} - script = find_batch_file(version) - if not script: - msg = 'VC version %s not installed' % version - debug('msv %s\n' % repr(msg)) - SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, msg) + try: + script = find_batch_file(version) + except VisualCException, e: + msg = str(e) + debug('Caught exception while looking for batch file (%s)' % msg) + warn_msg = "VC version %s not installed - C/C++ compilers most " \ + "likely not set correctly" % version + warn_msg += " \n Install versions are: %s" % get_installed_vcs() + SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) return None - print script - use_script = env.get('MSVC_USE_SCRIPT', True) if SCons.Util.is_String(use_script): @@ -249,13 +263,9 @@ def msvc_setup_env(env): 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)" % \ + msg = "MSVC error while executing %s with args %s (error was %s)" % \ (script, arg, str(e)) - print msg - print "+++++++++++++++++++++++++++++" - return None + raise SCons.Errors.UserError(msg) else: debug('msvc.get_default_env()\n') d = msvc.get_default_env() |