summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/SCons/scons-local/SCons/Tool/MSCommon/sdk.py')
-rw-r--r--3rdParty/SCons/scons-local/SCons/Tool/MSCommon/sdk.py196
1 files changed, 165 insertions, 31 deletions
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