diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-04-11 18:14:19 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-04-11 18:14:56 (GMT) |
commit | d9a29f93cd4ff505e264974febd0566ae29880ca (patch) | |
tree | 6eea9e476374863e93c80aacb76840ac24f0c50f /3rdParty/SCons/scons-local/SCons/Tool/MSCommon | |
parent | 73f845a3f380c5a1adbac2cf29e9f36cc9b498cf (diff) | |
download | swift-contrib-d9a29f93cd4ff505e264974febd0566ae29880ca.zip swift-contrib-d9a29f93cd4ff505e264974febd0566ae29880ca.tar.bz2 |
Update SCons to 1.3.0.d20100404.
Diffstat (limited to '3rdParty/SCons/scons-local/SCons/Tool/MSCommon')
7 files changed, 815 insertions, 166 deletions
diff --git a/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/__init__.py b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/__init__.py index 66afde3..01ba242 100644 --- a/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/__init__.py +++ b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation +# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/MSCommon/__init__.py 4043 2009/02/23 09:06:45 scons" +__revision__ = "src/engine/SCons/Tool/MSCommon/__init__.py 4761 2010/04/04 14:04:44 bdeegan" __doc__ = """ Common functions for Microsoft Visual Studio and Visual C/C++. @@ -36,10 +36,17 @@ import SCons.Errors import SCons.Platform.win32 import SCons.Util -from SCons.Tool.MSCommon.vs import detect_msvs, \ - get_default_version, \ +from SCons.Tool.MSCommon.sdk import mssdk_exists, \ + mssdk_setup_env + +from SCons.Tool.MSCommon.vc import msvc_exists, \ + msvc_setup_env, \ + msvc_setup_env_once + +from SCons.Tool.MSCommon.vs import get_default_version, \ get_vs_by_version, \ merge_default_version, \ + msvs_exists, \ query_versions # Local Variables: diff --git a/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/arch.py b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/arch.py new file mode 100644 index 0000000..d80df7d --- /dev/null +++ b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/arch.py @@ -0,0 +1,61 @@ +# +# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "src/engine/SCons/Tool/MSCommon/arch.py 4761 2010/04/04 14:04:44 bdeegan" + +__doc__ = """Module to define supported Windows chip architectures. +""" + +import os + +class ArchDefinition: + """ + A class for defining architecture-specific settings and logic. + """ + def __init__(self, arch, synonyms=[]): + self.arch = arch + self.synonyms = synonyms + +SupportedArchitectureList = [ + ArchitectureDefinition( + 'x86', + ['i386', 'i486', 'i586', 'i686'], + ), + + ArchitectureDefinition( + 'x86_64', + ['AMD64', 'amd64', 'em64t', 'EM64T', 'x86_64'], + ), + + ArchitectureDefinition( + 'ia64', + ['IA64'], + ), +] + +SupportedArchitectureMap = {} +for a in SupportedArchitectureList: + SupportedArchitectureMap[a.arch] = a + for s in a.synonyms: + SupportedArchitectureMap[s] = a + diff --git a/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/common.py b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/common.py index 0cac163..2e7f430 100644 --- a/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/common.py +++ b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/common.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation +# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -21,10 +21,10 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/MSCommon/common.py 4043 2009/02/23 09:06:45 scons" +__revision__ = "src/engine/SCons/Tool/MSCommon/common.py 4761 2010/04/04 14:04:44 bdeegan" __doc__ = """ -Common helper functions for working with +Common helper functions for working with the Microsoft tool chain. """ import copy @@ -36,7 +36,10 @@ import SCons.Util logfile = os.environ.get('SCONS_MSCOMMON_DEBUG') -if logfile: +if logfile == '-': + def debug(x): + print x +elif logfile: try: import logging except ImportError: @@ -48,23 +51,51 @@ else: debug = lambda x: None -# TODO(sgk): unused +_is_win64 = None + def is_win64(): - """Return true if running on windows 64 bits.""" - # Unfortunately, python does not seem to have anything useful: neither - # sys.platform nor os.name gives something different on windows running on - # 32 bits or 64 bits. Note that we don't care about whether python itself - # is 32 or 64 bits here - value = "Software\Wow6432Node" - yo = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, value)[0] - if yo is None: - return 0 - else: - return 1 + """Return true if running on windows 64 bits. + + Works whether python itself runs in 64 bits or 32 bits.""" + # Unfortunately, python does not provide a useful way to determine + # if the underlying Windows OS is 32-bit or 64-bit. Worse, whether + # the Python itself is 32-bit or 64-bit affects what it returns, + # so nothing in sys.* or os.* help. + + # Apparently the best solution is to use env vars that Windows + # sets. If PROCESSOR_ARCHITECTURE is not x86, then the python + # process is running in 64 bit mode (on a 64-bit OS, 64-bit + # hardware, obviously). + # If this python is 32-bit but the OS is 64, Windows will set + # ProgramW6432 and PROCESSOR_ARCHITEW6432 to non-null. + # (Checking for HKLM\Software\Wow6432Node in the registry doesn't + # work, because some 32-bit installers create it.) + global _is_win64 + if _is_win64 is None: + # I structured these tests to make it easy to add new ones or + # add exceptions in the future, because this is a bit fragile. + _is_win64 = False + if os.environ.get('PROCESSOR_ARCHITECTURE','x86') != 'x86': + _is_win64 = True + if os.environ.get('PROCESSOR_ARCHITEW6432'): + _is_win64 = True + if os.environ.get('ProgramW6432'): + _is_win64 = True + return _is_win64 + def read_reg(value): return SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, value)[0] +def has_reg(value): + """Return True if the given key exists in HKEY_LOCAL_MACHINE, False + otherwise.""" + try: + SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, value) + ret = True + except WindowsError: + ret = False + return ret # Functions for fetching environment variable settings from batch files. @@ -125,7 +156,7 @@ def parse_output(output, keep = ("INCLUDE", "LIB", "LIBPATH", "PATH")): for i in keep: rdk[i] = re.compile('%s=(.*)' % i, re.I) - def add_env(rmatch, key): + def add_env(rmatch, key, dkeep=dkeep): plist = rmatch.group(1).split(os.pathsep) for p in plist: # Do not add empty paths (when a var ends with ;) diff --git a/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/netframework.py b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/netframework.py index 33a0224..eaf9e9b 100644 --- a/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/netframework.py +++ b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/netframework.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation +# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/MSCommon/netframework.py 4043 2009/02/23 09:06:45 scons" +__revision__ = "src/engine/SCons/Tool/MSCommon/netframework.py 4761 2010/04/04 14:04:44 bdeegan" __doc__ = """ """ diff --git a/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/sdk.py b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/sdk.py index e11df4e..5ab58e3 100644 --- a/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/sdk.py +++ b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/sdk.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation +# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/MSCommon/sdk.py 4043 2009/02/23 09:06:45 scons" +__revision__ = "src/engine/SCons/Tool/MSCommon/sdk.py 4761 2010/04/04 14:04:44 bdeegan" __doc__ = """Module to detect the Platform/Windows SDK @@ -31,9 +31,12 @@ PSDK 2003 R1 is the earliest version detected. import os import SCons.Errors -from SCons.Tool.MSCommon.common import debug, read_reg import SCons.Util +import common + +debug = common.debug + # SDK Checks. This is of course a mess as everything else on MS platforms. Here # is what we do to detect the SDK: # @@ -69,24 +72,27 @@ class SDKDefinition: Return None if failed or the directory does not exist. """ if not SCons.Util.can_read_reg: - debug('find_sdk_dir(): can not read registry') + debug('find_sdk_dir(): can not read registry') return None hkey = self.HKEY_FMT % self.hkey_data + debug('find_sdk_dir(): checking registry:%s'%hkey) try: - sdk_dir = read_reg(hkey) + sdk_dir = common.read_reg(hkey) except WindowsError, e: - debug('find_sdk_dir(): no registry key %s' % hkey) + debug('find_sdk_dir(): no SDK registry key %s' % repr(hkey)) return None + debug('find_sdk_dir(): Trying SDK Dir: %s'%sdk_dir) + if not os.path.exists(sdk_dir): debug('find_sdk_dir(): %s not on file system' % sdk_dir) return None ftc = os.path.join(sdk_dir, self.sanity_check_file) if not os.path.exists(ftc): - debug("find_sdk_dir(): sanity check %s not found" % ftc) + debug("find_sdk_dir(): sanity check %s not found" % ftc) return None return sdk_dir @@ -99,6 +105,25 @@ class SDKDefinition: sdk_dir = self.find_sdk_dir() self._sdk_dir = sdk_dir return sdk_dir + + def get_sdk_vc_script(self,host_arch, target_arch): + """ Return the script to initialize the VC compiler installed by SDK + """ + + if (host_arch == 'amd64' and target_arch == 'x86'): + # No cross tools needed compiling 32 bits on 64 bit machine + host_arch=target_arch + + arch_string=target_arch + if (host_arch != target_arch): + arch_string='%s_%s'%(host_arch,target_arch) + + debug("sdk.py: get_sdk_vc_script():arch_string:%s host_arch:%s target_arch:%s"%(arch_string, + host_arch, + target_arch)) + file=self.vc_setup_scripts.get(arch_string,None) + debug("sdk.py: get_sdk_vc_script():file:%s"%file) + return file class WindowsSDK(SDKDefinition): """ @@ -118,6 +143,27 @@ class PlatformSDK(SDKDefinition): apply(SDKDefinition.__init__, (self,)+args, kw) self.hkey_data = self.uuid +# +# The list of VC initialization scripts installed by the SDK +# These should be tried if the vcvarsall.bat TARGET_ARCH fails +preSDK61VCSetupScripts = { 'x86' : r'bin\vcvars32.bat', + 'amd64' : r'bin\vcvarsamd64.bat', + 'x86_amd64': r'bin\vcvarsx86_amd64.bat', + 'x86_ia64' : r'bin\vcvarsx86_ia64.bat', + 'ia64' : r'bin\vcvarsia64.bat'} + +SDK61VCSetupScripts = {'x86' : r'bin\vcvars32.bat', + 'amd64' : r'bin\amd64\vcvarsamd64.bat', + 'x86_amd64': r'bin\x86_amd64\vcvarsx86_amd64.bat', + 'x86_ia64' : r'bin\x86_ia64\vcvarsx86_ia64.bat', + 'ia64' : r'bin\ia64\vcvarsia64.bat'} + +SDK70VCSetupScripts = { 'x86' : r'bin\vcvars32.bat', + 'amd64' : r'bin\vcvars64.bat', + 'x86_amd64': r'bin\vcvarsx86_amd64.bat', + 'x86_ia64' : r'bin\vcvarsx86_ia64.bat', + 'ia64' : r'bin\vcvarsia64.bat'} + # The list of support SDKs which we know how to detect. # # The first SDK found in the list is the one used by default if there @@ -126,22 +172,56 @@ class PlatformSDK(SDKDefinition): # # If you update this list, update the documentation in Tool/mssdk.xml. SupportedSDKList = [ + WindowsSDK('7.0', + sanity_check_file=r'bin\SetEnv.Cmd', + include_subdir='include', + lib_subdir={ + 'x86' : ['lib'], + 'x86_64' : [r'lib\x64'], + 'ia64' : [r'lib\ia64'], + }, + vc_setup_scripts = SDK70VCSetupScripts, + ), WindowsSDK('6.1', - sanity_check_file=r'include\windows.h'), + sanity_check_file=r'bin\SetEnv.Cmd', + include_subdir='include', + lib_subdir={ + 'x86' : ['lib'], + 'x86_64' : [r'lib\x64'], + 'ia64' : [r'lib\ia64'], + }, + vc_setup_scripts = SDK61VCSetupScripts, + ), WindowsSDK('6.0A', - sanity_check_file=r'include\windows.h'), + sanity_check_file=r'include\windows.h', + include_subdir='include', + lib_subdir={ + 'x86' : ['lib'], + 'x86_64' : [r'lib\x64'], + 'ia64' : [r'lib\ia64'], + }, + vc_setup_scripts = preSDK61VCSetupScripts, + ), WindowsSDK('6.0', - sanity_check_file=r'bin\gacutil.exe'), + sanity_check_file=r'bin\gacutil.exe', + include_subdir='include', + lib_subdir='lib', + vc_setup_scripts = preSDK61VCSetupScripts, + ), PlatformSDK('2003R2', sanity_check_file=r'SetEnv.Cmd', - uuid="D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1"), + uuid="D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1", + vc_setup_scripts = preSDK61VCSetupScripts, + ), PlatformSDK('2003R1', sanity_check_file=r'SetEnv.Cmd', - uuid="8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3"), + uuid="8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3", + vc_setup_scripts = preSDK61VCSetupScripts, + ), ] SupportedSDKMap = {} @@ -160,13 +240,14 @@ InstalledSDKMap = None def get_installed_sdks(): global InstalledSDKList global InstalledSDKMap + debug('sdk.py:get_installed_sdks()') if InstalledSDKList is None: InstalledSDKList = [] InstalledSDKMap = {} for sdk in SupportedSDKList: - debug('trying to find SDK %s' % sdk.version) + debug('MSCommon/sdk.py: trying to find SDK %s' % sdk.version) if sdk.get_sdk_dir(): - debug('found SDK %s' % sdk.version) + debug('MSCommon/sdk.py:found SDK %s' % sdk.version) InstalledSDKList.append(sdk) InstalledSDKMap[sdk.version] = sdk return InstalledSDKList @@ -181,6 +262,7 @@ SDKEnvironmentUpdates = {} def set_sdk_by_directory(env, sdk_dir): global SDKEnvironmentUpdates + debug('set_sdk_by_directory: Using dir:%s'%sdk_dir) try: env_tuple_list = SDKEnvironmentUpdates[sdk_dir] except KeyError: @@ -215,7 +297,7 @@ def get_cur_sdk_dir_from_reg(): return None try: - val = read_reg(_CURINSTALLED_SDK_HKEY_ROOT) + val = common.read_reg(_CURINSTALLED_SDK_HKEY_ROOT) debug("Found current sdk dir in registry: %s" % val) except WindowsError, e: debug("Did not find current sdk in registry") @@ -227,28 +309,80 @@ def get_cur_sdk_dir_from_reg(): return val - -def detect_sdk(): - return (len(get_installed_sdks()) > 0) - -def set_sdk_by_version(env, mssdk): +def get_sdk_by_version(mssdk): if not SupportedSDKMap.has_key(mssdk): msg = "SDK version %s is not supported" % repr(mssdk) raise SCons.Errors.UserError, msg get_installed_sdks() - sdk = InstalledSDKMap.get(mssdk) - if not sdk: - msg = "SDK version %s is not installed" % repr(mssdk) - raise SCons.Errors.UserError, msg - set_sdk_by_directory(env, sdk.get_sdk_dir()) + return InstalledSDKMap.get(mssdk) -def set_default_sdk(env, msver): +def get_default_sdk(): """Set up the default Platform/Windows SDK.""" - # For MSVS < 8, use integrated windows sdk by default - if msver >= 8: - sdks = get_installed_sdks() - if len(sdks) > 0: - set_sdk_by_directory(env, sdks[0].get_sdk_dir()) + get_installed_sdks() + if not InstalledSDKList: + return None + return InstalledSDKList[0] + + + + +def mssdk_setup_env(env): + debug('sdk.py:mssdk_setup_env()') + if env.has_key('MSSDK_DIR'): + sdk_dir = env['MSSDK_DIR'] + if sdk_dir is None: + return + sdk_dir = env.subst(sdk_dir) + debug('sdk.py:mssdk_setup_env: Using MSSDK_DIR:%s'%sdk_dir) + elif env.has_key('MSSDK_VERSION'): + sdk_version = env['MSSDK_VERSION'] + if sdk_version is None: + msg = "SDK version %s is not installed" % repr(mssdk) + raise SCons.Errors.UserError, msg + sdk_version = env.subst(sdk_version) + mssdk = get_sdk_by_version(sdk_version) + sdk_dir = mssdk.get_sdk_dir() + debug('sdk.py:mssdk_setup_env: Using MSSDK_VERSION:%s'%sdk_dir) + elif env.has_key('MSVS_VERSION'): + msvs_version = env['MSVS_VERSION'] + debug('sdk.py:mssdk_setup_env:Getting MSVS_VERSION from env:%s'%msvs_version) + if msvs_version is None: + debug('sdk.py:mssdk_setup_env thinks msvs_version is None') + return + msvs_version = env.subst(msvs_version) + import vs + msvs = vs.get_vs_by_version(msvs_version) + debug('sdk.py:mssdk_setup_env:msvs is :%s'%msvs) + if not msvs: + debug('sdk.py:mssdk_setup_env: no VS version detected, bailingout:%s'%msvs) + return + sdk_version = msvs.sdk_version + debug('sdk.py:msvs.sdk_version is %s'%sdk_version) + if not sdk_version: + return + mssdk = get_sdk_by_version(sdk_version) + if not mssdk: + mssdk = get_default_sdk() + if not mssdk: + return + sdk_dir = mssdk.get_sdk_dir() + debug('sdk.py:mssdk_setup_env: Using MSVS_VERSION:%s'%sdk_dir) + else: + mssdk = get_default_sdk() + if not mssdk: + return + sdk_dir = mssdk.get_sdk_dir() + debug('sdk.py:mssdk_setup_env: not using any env values. sdk_dir:%s'%sdk_dir) + + set_sdk_by_directory(env, sdk_dir) + + #print "No MSVS_VERSION: this is likely to be a bug" + +def mssdk_exists(version=None): + sdks = get_installed_sdks() + if version is None: + return len(sdks) > 0 + return sdks.has_key(version) # Local Variables: # tab-width:4 diff --git a/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/vc.py b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/vc.py new file mode 100644 index 0000000..bf2412b --- /dev/null +++ b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/vc.py @@ -0,0 +1,412 @@ +# +# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +# TODO: +# * supported arch for versions: for old versions of batch file without +# argument, giving bogus argument cannot be detected, so we have to hardcode +# this here +# * print warning when msvc version specified but not found +# * find out why warning do not print +# * test on 64 bits XP + VS 2005 (and VS 6 if possible) +# * SDK +# * Assembly +__revision__ = "src/engine/SCons/Tool/MSCommon/vc.py 4761 2010/04/04 14:04:44 bdeegan" + +__doc__ = """Module for Visual C/C++ detection and configuration. +""" +import SCons.compat + +import string +import os +import platform + +import SCons.Warnings + +import common + +debug = common.debug + +import sdk + +get_installed_sdks = sdk.get_installed_sdks + + +class VisualCException(Exception): + pass + +class UnsupportedVersion(VisualCException): + pass + +class UnsupportedArch(VisualCException): + pass + +class MissingConfiguration(VisualCException): + pass + +class NoVersionFound(VisualCException): + pass + +class BatchFileExecutionError(VisualCException): + pass + +# Dict to 'canonalize' the arch +_ARCH_TO_CANONICAL = { + "x86": "x86", + "amd64": "amd64", + "i386": "x86", + "emt64": "amd64", + "x86_64": "amd64", + "itanium": "ia64", + "ia64": "ia64", +} + +# Given a (host, target) tuple, return the argument for the bat file. Both host +# and targets should be canonalized. +_HOST_TARGET_ARCH_TO_BAT_ARCH = { + ("x86", "x86"): "x86", + ("x86", "amd64"): "x86_amd64", + ("amd64", "amd64"): "amd64", + ("amd64", "x86"): "x86", + ("x86", "ia64"): "x86_ia64" +} + +def get_host_target(env): + host_platform = env.get('HOST_ARCH') + if not host_platform: + host_platform = platform.machine() + # TODO(2.5): the native Python platform.machine() function returns + # '' on all Python versions before 2.6, after which it also uses + # PROCESSOR_ARCHITECTURE. + if not host_platform: + host_platform = os.environ.get('PROCESSOR_ARCHITECTURE', '') + target_platform = env.get('TARGET_ARCH') + if not target_platform: + target_platform = host_platform + + try: + host = _ARCH_TO_CANONICAL[host_platform] + except KeyError, e: + msg = "Unrecognized host architecture %s" + raise ValueError(msg % repr(host_platform)) + + try: + target = _ARCH_TO_CANONICAL[target_platform] + except KeyError, e: + raise ValueError("Unrecognized target architecture %s" % target_platform) + + return (host, target) + +_VCVER = ["10.0", "9.0", "9.0Exp","8.0", "8.0Exp","7.1", "7.0", "6.0"] + +_VCVER_TO_PRODUCT_DIR = { + '10.0': [ + r'Microsoft\VisualStudio\10.0\Setup\VC\ProductDir'], + '9.0': [ + r'Microsoft\VisualStudio\9.0\Setup\VC\ProductDir'], + '9.0Exp' : [ + r'Microsoft\VCExpress\9.0\Setup\VC\ProductDir'], + '8.0': [ + r'Microsoft\VisualStudio\8.0\Setup\VC\ProductDir'], + '8.0Exp': [ + r'Microsoft\VCExpress\8.0\Setup\VC\ProductDir'], + '7.1': [ + r'Microsoft\VisualStudio\7.1\Setup\VC\ProductDir'], + '7.0': [ + r'Microsoft\VisualStudio\7.0\Setup\VC\ProductDir'], + '6.0': [ + r'Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++\ProductDir'] +} + +def msvc_version_to_maj_min(msvc_version): + msvc_ver_numeric = string.join(filter(lambda x: x in string.digits + ".", msvc_version), '') + + t = msvc_version_numeric.split(".") + if not len(t) == 2: + raise ValueError("Unrecognized version %s" % msvc_version) + try: + maj = int(t[0]) + min = int(t[1]) + return maj, min + except ValueError, e: + raise ValueError("Unrecognized version %s" % msvc_version) + +def is_host_target_supported(host_target, msvc_version): + """Return True if the given (host, target) tuple is supported given the + msvc version. + + Parameters + ---------- + host_target: tuple + tuple of (canonalized) host-target, e.g. ("x86", "amd64") for cross + compilation from 32 bits windows to 64 bits. + msvc_version: str + msvc version (major.minor, e.g. 10.0) + + Note + ---- + This only check whether a given version *may* support the given (host, + target), not that the toolchain is actually present on the machine. + """ + # We assume that any Visual Studio version supports x86 as a target + if host_target[1] != "x86": + maj, min = msvc_version_to_maj_min(msvc_version) + if maj < 8: + return False + + return True + +def find_vc_pdir(msvc_version): + """Try to find the product directory for the given + version. + + Note + ---- + If for some reason the requested version could not be found, an + exception which inherits from VisualCException will be raised.""" + root = 'Software\\' + if common.is_win64(): + root = root + 'Wow6432Node\\' + try: + hkeys = _VCVER_TO_PRODUCT_DIR[msvc_version] + except KeyError: + debug("Unknown version of MSVC: %s" % msvc_version) + raise UnsupportedVersion("Unknown version %s" % msvc_version) + + for key in hkeys: + key = root + key + try: + comps = common.read_reg(key) + except WindowsError, e: + debug('find_vc_dir(): no VC registry key %s' % repr(key)) + else: + debug('find_vc_dir(): found VC in registry: %s' % comps) + if os.path.exists(comps): + return comps + else: + debug('find_vc_dir(): reg says dir is %s, but it does not exist. (ignoring)'\ + % comps) + raise MissingConfiguration("registry dir %s not found on the filesystem" % comps) + return None + +def find_batch_file(env,msvc_version): + """ + Find the location of the batch script which should set up the compiler + for any TARGET_ARCH whose compilers were installed by Visual Studio/VCExpress + """ + pdir = find_vc_pdir(msvc_version) + if pdir is None: + raise NoVersionFound("No version of Visual Studio found") + + debug('vc.py: find_batch_file() pdir:%s'%pdir) + + # filter out e.g. "Exp" from the version name + msvc_ver_numeric = string.join(filter(lambda x: x in string.digits + ".", msvc_version), '') + vernum = float(msvc_ver_numeric) + if 7 <= vernum < 8: + pdir = os.path.join(pdir, os.pardir, "Common7", "Tools") + batfilename = os.path.join(pdir, "vsvars32.bat") + elif vernum < 7: + pdir = os.path.join(pdir, "Bin") + batfilename = os.path.join(pdir, "vcvars32.bat") + else: # >= 8 + batfilename = os.path.join(pdir, "vcvarsall.bat") + + if not os.path.exists(batfilename): + debug("Not found: %s" % batfilename) + batfilename = None + + installed_sdks=get_installed_sdks() + (host_arch,target_arch)=get_host_target(env) + for _sdk in installed_sdks: + sdk_bat_file=_sdk.get_sdk_vc_script(host_arch,target_arch) + sdk_bat_file_path=os.path.join(pdir,sdk_bat_file) + debug('vc.py:find_batch_file() sdk_bat_file_path:%s'%sdk_bat_file_path) + if os.path.exists(sdk_bat_file_path): + return (batfilename,sdk_bat_file_path) + else: + debug("vc.py:find_batch_file() not found:%s"%sdk_bat_file_path) + else: + return (batfilename,None) + +__INSTALLED_VCS_RUN = None + +def cached_get_installed_vcs(): + global __INSTALLED_VCS_RUN + + if __INSTALLED_VCS_RUN is None: + ret = get_installed_vcs() + __INSTALLED_VCS_RUN = ret + + return __INSTALLED_VCS_RUN + +def get_installed_vcs(): + installed_versions = [] + for ver in _VCVER: + debug('trying to find VC %s' % ver) + try: + if find_vc_pdir(ver): + debug('found VC %s' % ver) + installed_versions.append(ver) + else: + debug('find_vc_pdir return None for ver %s' % ver) + except VisualCException, e: + debug('did not find VC %s: caught exception %s' % (ver, str(e))) + return installed_versions + +def reset_installed_vcs(): + """Make it try again to find VC. This is just for the tests.""" + __INSTALLED_VCS_RUN = None + +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): + debug('get_default_version()') + + msvc_version = env.get('MSVC_VERSION') + msvs_version = env.get('MSVS_VERSION') + + debug('get_default_version(): msvc_version:%s msvs_version:%s'%(msvc_version,msvs_version)) + + if msvs_version and not msvc_version: + SCons.Warnings.warn( + SCons.Warnings.DeprecatedWarning, + "MSVS_VERSION is deprecated: please use MSVC_VERSION instead ") + return msvs_version + elif msvc_version and msvs_version: + if not msvc_version == msvs_version: + SCons.Warnings.warn( + SCons.Warnings.VisualVersionMismatch, + "Requested msvc version (%s) and msvs version (%s) do " \ + "not match: please use MSVC_VERSION only to request a " \ + "visual studio version, MSVS_VERSION is deprecated" \ + % (msvc_version, msvs_version)) + return msvs_version + if not msvc_version: + installed_vcs = cached_get_installed_vcs() + debug('installed_vcs:%s' % installed_vcs) + if not installed_vcs: + msg = 'No installed VCs' + debug('msv %s\n' % repr(msg)) + SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, msg) + return None + msvc_version = installed_vcs[0] + debug('msvc_setup_env: using default installed MSVC version %s\n' % repr(msvc_version)) + + return msvc_version + +def msvc_setup_env_once(env): + try: + has_run = env["MSVC_SETUP_RUN"] + except KeyError: + has_run = False + + if not has_run: + msvc_setup_env(env) + env["MSVC_SETUP_RUN"] = True + +def msvc_setup_env(env): + debug('msvc_setup_env()') + + version = get_default_version(env) + if version is None: + warn_msg = "No version of Visual Studio compiler found - C/C++ " \ + "compilers most likely not set correctly" + SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) + return None + debug('msvc_setup_env: using specified MSVC version %s\n' % repr(version)) + + # XXX: we set-up both MSVS version for backward + # compatibility with the msvs tool + env['MSVC_VERSION'] = version + env['MSVS_VERSION'] = version + env['MSVS'] = {} + + try: + (vc_script,sdk_script) = find_batch_file(env,version) + debug('vc.py:msvc_setup_env() vc_script:%s sdk_script:%s'%(vc_script,sdk_script)) + 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 are most likely not set correctly.\n" + \ + " Installed versions are: %s" + warn_msg = warn_msg % (version, cached_get_installed_vcs()) + SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) + return None + + debug('vc.py:msvc_setup_env() vc_script:%s sdk_script:%s'%(vc_script,sdk_script)) + use_script = env.get('MSVC_USE_SCRIPT', True) + if SCons.Util.is_String(use_script): + debug('use_script 1 %s\n' % repr(use_script)) + d = script_env(use_script) + elif use_script: + host_platform, target_platform = get_host_target(env) + host_target = (host_platform, target_platform) + if not is_host_target_supported(host_target, version): + warn_msg = "host, target = %s not supported for MSVC version %s" % \ + (host_target, version) + SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) + arg = _HOST_TARGET_ARCH_TO_BAT_ARCH[host_target] + debug('use_script 2 %s, args:%s\n' % (repr(vc_script), arg)) + if vc_script: + try: + d = script_env(vc_script, args=arg) + except BatchFileExecutionError, e: + debug('use_script 3: failed running VC script %s: %s: Error:%s'%(repr(vc_script),arg,e)) + vc_script=None + if not vc_script and sdk_script: + debug('use_script 4: trying sdk script: %s'%(sdk_script)) + try: + d = script_env(sdk_script,args=[]) + except BatchFileExecutionError,e: + debug('use_script 5: failed running SDK script %s: Error:%s'%(repr(sdk_script),e)) + return None + elif not vc_script and not sdk_script: + debug('use_script 6: Neither VC script nor SDK script found') + return None + + else: + debug('MSVC_USE_SCRIPT set to False') + warn_msg = "MSVC_USE_SCRIPT set to False, assuming environment " \ + "set correctly." + SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) + return None + + for k, v in d.items(): + debug('vc.py:msvc_setup_env() env:%s -> %s'%(k,v)) + env.PrependENVPath(k, v, delete_existing=True) + +def msvc_exists(version=None): + vcs = cached_get_installed_vcs() + if version is None: + return len(vcs) > 0 + return version in vcs + diff --git a/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/vs.py b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/vs.py index 2203e20..2dce362 100644 --- a/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/vs.py +++ b/3rdParty/SCons/scons-local/SCons/Tool/MSCommon/vs.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation +# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/MSCommon/vs.py 4043 2009/02/23 09:06:45 scons" +__revision__ = "src/engine/SCons/Tool/MSCommon/vs.py 4761 2010/04/04 14:04:44 bdeegan" __doc__ = """Module to detect Visual Studio and/or Visual C/C++ """ @@ -31,11 +31,14 @@ import os import SCons.Errors import SCons.Util -from SCons.Tool.MSCommon.common import debug, \ - read_reg, \ - normalize_env, \ - get_output, \ - parse_output +from common import debug, \ + get_output, \ + is_win64, \ + normalize_env, \ + parse_output, \ + read_reg + +import SCons.Tool.MSCommon.vc class VisualStudio: """ @@ -44,70 +47,75 @@ class VisualStudio: """ def __init__(self, version, **kw): self.version = version + kw['vc_version'] = kw.get('vc_version', version) + kw['sdk_version'] = kw.get('sdk_version', version) self.__dict__.update(kw) self._cache = {} # def find_batch_file(self): - """Try to find the Visual Studio or Visual C/C++ batch file. - - Return None if failed or the batch file does not exist. - """ - pdir = self.get_vc_product_dir() - if not pdir: - debug('find_batch_file(): no pdir') + vs_dir = self.get_vs_dir() + if not vs_dir: + debug('find_executable(): no vs_dir') return None - batch_file = os.path.normpath(os.path.join(pdir, self.batch_file)) + batch_file = os.path.join(vs_dir, self.batch_file_path) batch_file = os.path.normpath(batch_file) if not os.path.isfile(batch_file): debug('find_batch_file(): %s not on file system' % batch_file) return None return batch_file + def find_vs_dir_by_vc(self): + SCons.Tool.MSCommon.vc.get_installed_vcs() + dir = SCons.Tool.MSCommon.vc.find_vc_pdir(self.vc_version) + if not dir: + debug('find_vs_dir(): no installed VC %s' % self.vc_version) + return None + return dir + + def find_vs_dir_by_reg(self): + root = 'Software\\' + + if is_win64(): + root = root + 'Wow6432Node\\' + for key in self.hkeys: + if key=='use_dir': + return self.find_vs_dir_by_vc() + key = root + key + try: + comps = read_reg(key) + except WindowsError, e: + debug('find_vs_dir_by_reg(): no VS registry key %s' % repr(key)) + else: + debug('find_vs_dir_by_reg(): found VS in registry: %s' % comps) + return comps + return None + + def find_vs_dir(self): + """ Can use registry or location of VC to find vs dir + First try to find by registry, and if that fails find via VC dir + """ + + + if True: + vs_dir=self.find_vs_dir_by_reg() + return vs_dir + else: + return self.find_vs_dir_by_vc() + def find_executable(self): - pdir = self.get_vc_product_dir() - if not pdir: - debug('find_executable(): no pdir') + vs_dir = self.get_vs_dir() + if not vs_dir: + debug('find_executable(): no vs_dir (%s)'%vs_dir) return None - executable = os.path.join(pdir, self.executable_path) + executable = os.path.join(vs_dir, self.executable_path) executable = os.path.normpath(executable) if not os.path.isfile(executable): debug('find_executable(): %s not on file system' % executable) return None return executable - - def find_vc_product_dir(self): - if not SCons.Util.can_read_reg: - debug('find_vc_product_dir(): can not read registry') - return None - key = self.hkey_root + '\\' + self.vc_product_dir_key - try: - comps = read_reg(key) - except WindowsError, e: - debug('find_vc_product_dir(): no registry key %s' % key) - else: - if self.batch_file_dir_reg_relpath: - comps = os.path.join(comps, self.batch_file_dir_reg_relpath) - comps = os.path.normpath(comps) - if os.path.exists(comps): - return comps - else: - debug('find_vc_product_dir(): %s not on file system' % comps) - - d = os.environ.get(self.common_tools_var) - if not d: - msg = 'find_vc_product_dir(): no %s variable' - debug(msg % self.common_tools_var) - return None - if not os.path.isdir(d): - debug('find_vc_product_dir(): %s not on file system' % d) - return None - if self.batch_file_dir_env_relpath: - d = os.path.join(d, self.batch_file_dir_env_relpath) - d = os.path.normpath(d) - return d - + # def get_batch_file(self): @@ -120,12 +128,22 @@ class VisualStudio: def get_executable(self): try: + debug('get_executable using cache:%s'%self._cache['executable']) return self._cache['executable'] except KeyError: executable = self.find_executable() self._cache['executable'] = executable + debug('get_executable not in cache:%s'%executable) return executable + def get_vs_dir(self): + try: + return self._cache['vs_dir'] + except KeyError: + vs_dir = self.find_vs_dir() + self._cache['vs_dir'] = vs_dir + return vs_dir + def get_supported_arch(self): try: return self._cache['supported_arch'] @@ -135,14 +153,6 @@ class VisualStudio: self._cache['supported_arch'] = self.supported_arch return self.supported_arch - def get_vc_product_dir(self): - try: - return self._cache['vc_product_dir'] - except KeyError: - vc_product_dir = self.find_vc_product_dir() - self._cache['vc_product_dir'] = vc_product_dir - return vc_product_dir - def reset(self): self._cache = {} @@ -197,10 +207,6 @@ SupportedVSList = [ #VisualStudio('TBD', # hkey_root=r'TBD', # common_tools_var='TBD', - # batch_file='TBD', - # vc_product_dir_key=r'TBD', - # batch_file_dir_reg_relpath=None, - # batch_file_dir_env_relpath=r'TBD', # executable_path=r'TBD', # default_dirname='TBD', #), @@ -209,13 +215,11 @@ SupportedVSList = [ # The batch file we look for is in the VC directory, # so the devenv.com executable is up in ..\..\Common7\IDE. VisualStudio('9.0', - hkey_root=r'Software\Microsoft\VisualStudio\9.0', + sdk_version='6.1', + hkeys=[r'Microsoft\VisualStudio\9.0\Setup\VS\ProductDir'], common_tools_var='VS90COMNTOOLS', - batch_file='vcvarsall.bat', - vc_product_dir_key=r'Setup\VC\ProductDir', - batch_file_dir_reg_relpath=None, - batch_file_dir_env_relpath=r'..\..\VC', - executable_path=r'..\Common7\IDE\devenv.com', + executable_path=r'Common7\IDE\devenv.com', + batch_file_path=r'Common7\Tools\vsvars32.bat', default_dirname='Microsoft Visual Studio 9', supported_arch=['x86', 'amd64'], ), @@ -224,13 +228,12 @@ SupportedVSList = [ # The batch file we look for is in the VC directory, # so the VCExpress.exe executable is up in ..\..\Common7\IDE. VisualStudio('9.0Exp', - hkey_root=r'Software\Microsoft\VisualStudio\9.0', + vc_version='9.0', + sdk_version='6.1', + hkeys=[r'Microsoft\VCExpress\9.0\Setup\VS\ProductDir'], common_tools_var='VS90COMNTOOLS', - batch_file='vcvarsall.bat', - vc_product_dir_key=r'Setup\VC\ProductDir', - batch_file_dir_reg_relpath=None, - batch_file_dir_env_relpath=r'..\..\VC', - executable_path=r'..\Common7\IDE\VCExpress.exe', + executable_path=r'Common7\IDE\VCExpress.exe', + batch_file_path=r'Common7\Tools\vsvars32.bat', default_dirname='Microsoft Visual Studio 9', supported_arch=['x86'], ), @@ -239,13 +242,11 @@ SupportedVSList = [ # The batch file we look for is in the VC directory, # so the devenv.com executable is up in ..\..\Common7\IDE. VisualStudio('8.0', - hkey_root=r'Software\Microsoft\VisualStudio\8.0', + sdk_version='6.0A', + hkeys=[r'Microsoft\VisualStudio\8.0\Setup\VS\ProductDir'], common_tools_var='VS80COMNTOOLS', - batch_file='vcvarsall.bat', - vc_product_dir_key=r'Setup\VC\ProductDir', - batch_file_dir_reg_relpath=None, - batch_file_dir_env_relpath=r'..\..\VC', - executable_path=r'..\Common7\IDE\devenv.com', + executable_path=r'Common7\IDE\devenv.com', + batch_file_path=r'Common7\Tools\vsvars32.bat', default_dirname='Microsoft Visual Studio 8', supported_arch=['x86', 'amd64'], ), @@ -254,15 +255,12 @@ SupportedVSList = [ # The batch file we look for is in the VC directory, # so the VCExpress.exe executable is up in ..\..\Common7\IDE. VisualStudio('8.0Exp', - hkey_root=r'Software\Microsoft\VCExpress\8.0', + vc_version='8.0Exp', + sdk_version='6.0A', + hkeys=[r'Microsoft\VCExpress\8.0\Setup\VS\ProductDir'], common_tools_var='VS80COMNTOOLS', - batch_file='vcvarsall.bat', - vc_product_dir_key=r'Setup\VC\ProductDir', - batch_file_dir_reg_relpath=None, - batch_file_dir_env_relpath=r'..\..\VC', - # The batch file is in the VC directory, so - # so the devenv.com executable is next door in ..\IDE. - executable_path=r'..\Common7\IDE\VCExpress.exe', + executable_path=r'Common7\IDE\VCExpress.exe', + batch_file_path=r'Common7\Tools\vsvars32.bat', default_dirname='Microsoft Visual Studio 8', supported_arch=['x86'], ), @@ -271,14 +269,12 @@ SupportedVSList = [ # The batch file we look for is in the Common7\Tools directory, # so the devenv.com executable is next door in ..\IDE. VisualStudio('7.1', - hkey_root=r'Software\Microsoft\VisualStudio\7.1', + sdk_version='6.0', + hkeys=[r'Microsoft\VisualStudio\7.1\Setup\VS\ProductDir'], common_tools_var='VS71COMNTOOLS', - batch_file='vsvars32.bat', - vc_product_dir_key=r'Setup\VC\ProductDir', - batch_file_dir_reg_relpath=r'..\Common7\Tools', - batch_file_dir_env_relpath=None, - executable_path=r'..\IDE\devenv.com', - default_dirname='Microsoft Visual Studio .NET', + executable_path=r'Common7\IDE\devenv.com', + batch_file_path=r'Common7\Tools\vsvars32.bat', + default_dirname='Microsoft Visual Studio .NET 2003', supported_arch=['x86'], ), @@ -286,26 +282,23 @@ SupportedVSList = [ # The batch file we look for is in the Common7\Tools directory, # so the devenv.com executable is next door in ..\IDE. VisualStudio('7.0', - hkey_root=r'Software\Microsoft\VisualStudio\7.0', + sdk_version='2003R2', + hkeys=[r'Microsoft\VisualStudio\7.0\Setup\VS\ProductDir'], common_tools_var='VS70COMNTOOLS', - batch_file='vsvars32.bat', - vc_product_dir_key=r'Setup\VC\ProductDir', - batch_file_dir_reg_relpath=r'..\Common7\Tools', - batch_file_dir_env_relpath=None, - executable_path=r'..\IDE\devenv.com', + executable_path=r'IDE\devenv.com', + batch_file_path=r'Common7\Tools\vsvars32.bat', default_dirname='Microsoft Visual Studio .NET', supported_arch=['x86'], ), # Visual Studio 6.0 VisualStudio('6.0', - hkey_root=r'Software\Microsoft\VisualStudio\6.0', + sdk_version='2003R1', + hkeys=[r'Microsoft\VisualStudio\6.0\Setup\Microsoft Visual Studio\ProductDir', + 'use_dir'], common_tools_var='VS60COMNTOOLS', - batch_file='vcvars32.bat', - vc_product_dir_key='Setup\Microsoft Visual C++\ProductDir', - batch_file_dir_reg_relpath='Bin', - batch_file_dir_env_relpath=None, executable_path=r'Common\MSDev98\Bin\MSDEV.COM', + batch_file_path=r'Common7\Tools\vsvars32.bat', default_dirname='Microsoft Visual Studio', supported_arch=['x86'], ), @@ -323,7 +316,7 @@ for vs in SupportedVSList: # requested, and cache it. InstalledVSList = None -InstalledVSMap = None +InstalledVSMap = None def get_installed_visual_studios(): global InstalledVSList @@ -343,10 +336,14 @@ def reset_installed_visual_studios(): global InstalledVSList global InstalledVSMap InstalledVSList = None - InstalledVSMap = None + InstalledVSMap = None for vs in SupportedVSList: vs.reset() - + + # Need to clear installed VC's as well as they are used in finding + # installed VS's + SCons.Tool.MSCommon.vc.reset_installed_vcs() + # We may be asked to update multiple construction environments with # SDK information. When doing this, we check on-disk for whether @@ -380,15 +377,21 @@ def reset_installed_visual_studios(): # for variable, directory in env_tuple_list: # env.PrependENVPath(variable, directory) -def detect_msvs(): +def msvs_exists(): return (len(get_installed_visual_studios()) > 0) def get_vs_by_version(msvs): + global InstalledVSMap + global SupportedVSMap + + debug('vs.py:get_vs_by_version()') if not SupportedVSMap.has_key(msvs): msg = "Visual Studio version %s is not supported" % repr(msvs) raise SCons.Errors.UserError, msg get_installed_visual_studios() vs = InstalledVSMap.get(msvs) + debug('InstalledVSMap:%s'%InstalledVSMap) + debug('vs.py:get_vs_by_version: found vs:%s'%vs) # Some check like this would let us provide a useful error message # if they try to set a Visual Studio version that's not installed. # However, we also want to be able to run tests (like the unit @@ -456,10 +459,11 @@ def merge_default_version(env): version = get_default_version(env) arch = get_default_arch(env) +def msvs_setup_env(env): + batfilename = msvs.get_batch_file() msvs = get_vs_by_version(version) if msvs is None: return - batfilename = msvs.get_batch_file() # XXX: I think this is broken. This will silently set a bogus tool instead # of failing, but there is no other way with the current scons tool |