summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2009-11-19 04:51:43 (GMT)
committerDavid Cournapeau <cournape@gmail.com>2009-11-19 04:51:43 (GMT)
commitc2260bafc76ab8d1572bd6ead6c670abb8b0f0ee (patch)
tree16db6e24e557ea86db76999e609ee3dcb925ca49 /src
parentf9ae6028bc06d48dfaf3a6dee906e428cf33127f (diff)
downloadSCons-c2260bafc76ab8d1572bd6ead6c670abb8b0f0ee.zip
SCons-c2260bafc76ab8d1572bd6ead6c670abb8b0f0ee.tar.gz
SCons-c2260bafc76ab8d1572bd6ead6c670abb8b0f0ee.tar.bz2
ENH: refactor function to get msvc version.
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Tool/MSCommon/vc.py36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py
index 66ac68e..3d78ae8 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))