From a57844e6d13a77f71431e4fab733267184a7cd69 Mon Sep 17 00:00:00 2001 From: cournape Date: Thu, 19 Nov 2009 04:51:43 +0000 Subject: [PATCH] ENH: refactor function to get msvc version. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4433 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Tool/MSCommon/vc.py | 36 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index 66ac68e0..3d78ae89 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -280,29 +280,29 @@ def script_env(script): stdout = common.get_output(script) return common.parse_output(stdout) -def msvc_setup_env(env): - debug('msvc_setup_env()') - installed_vcs = get_installed_vcs() - debug('InstalledVCMap:%s'%InstalledVCMap) +def get_default_version(env): + debug('get_default_version()') + msvc_version = env.get('MSVC_VERSION') if not msvc_version: + installed_vcs = get_installed_vcs() + debug('InstalledVCMap:%s'%InstalledVCMap) if not installed_vcs: msg = 'No installed VCs' debug('msv %s\n' % repr(msg)) SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, msg) - return + return None msvc = installed_vcs[0] msvc_version = msvc.version - env['MSVC_VERSION'] = msvc_version debug('msvc_setup_env: using default installed MSVC version %s\n' % repr(msvc_version)) - else: - msvc = InstalledVCMap.get(msvc_version) - debug('msvc_setup_env: using specified MSVC version %s\n' % repr(msvc_version)) - if not msvc: - msg = 'VC version %s not installed' % msvc_version - debug('msv %s\n' % repr(msg)) - SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, msg) - return + + return msvc_version + +def msvc_setup_env(env): + debug('msvc_setup_env()') + + version = get_default_version(env) + env['MSVC_VERSION'] = version host_platform = env.get('HOST_ARCH') if not host_platform: @@ -312,6 +312,14 @@ def msvc_setup_env(env): if not target_platform: target_platform = host_platform + msvc = InstalledVCMap.get(version) + debug('msvc_setup_env: using specified MSVC version %s\n' % repr(version)) + if not msvc: + msg = 'VC version %s not installed' % version + debug('msv %s\n' % repr(msg)) + SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, msg) + return None + use_script = env.get('MSVC_USE_SCRIPT', True) if SCons.Util.is_String(use_script): debug('use_script 1 %s\n' % repr(use_script)) -- 2.26.2