summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/engine/SCons/Tool/MSCommon/sdk.py50
-rw-r--r--src/engine/SCons/Tool/MSCommon/vc.py44
-rw-r--r--src/engine/SCons/compat/_scons_subprocess.py32
3 files changed, 98 insertions, 28 deletions
diff --git a/src/engine/SCons/Tool/MSCommon/sdk.py b/src/engine/SCons/Tool/MSCommon/sdk.py
index 5491a87..c3290a8 100644
--- a/src/engine/SCons/Tool/MSCommon/sdk.py
+++ b/src/engine/SCons/Tool/MSCommon/sdk.py
@@ -102,6 +102,21 @@ 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
+ """
+
+ arch_string=target_arch
+ if (host_arch != target_arch):
+ arch_string='%s_%s'%(host_arch,target_arch)
+
+ #print "arch_string:%s host_arch:%s target_arch:%s"%(arch_string,
+ # host_arch,
+ # target_arch)
+ file=self.vc_setup_scripts.get(arch_string,None)
+ #print "FILE:%s"%file
+ return file
class WindowsSDK(SDKDefinition):
"""
@@ -121,6 +136,21 @@ 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'}
+
+SDk61AndLaterVCSetupScripts = {'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'}
+
# 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
@@ -129,6 +159,16 @@ 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 = SDk61AndLaterVCSetupScripts,
+ ),
WindowsSDK('6.1',
sanity_check_file=r'bin\SetEnv.Cmd',
include_subdir='include',
@@ -137,6 +177,7 @@ SupportedSDKList = [
'x86_64' : [r'lib\x64'],
'ia64' : [r'lib\ia64'],
},
+ vc_setup_scripts = SDk61AndLaterVCSetupScripts,
),
WindowsSDK('6.0A',
@@ -147,22 +188,26 @@ SupportedSDKList = [
'x86_64' : [r'lib\x64'],
'ia64' : [r'lib\ia64'],
},
+ vc_setup_scripts = preSDK61VCSetupScripts,
),
WindowsSDK('6.0',
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",
+ vc_setup_scripts = preSDK61VCSetupScripts,
),
]
@@ -203,6 +248,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:
@@ -264,7 +310,7 @@ def get_default_sdk():
return InstalledSDKList[0]
def mssdk_setup_env(env):
- debug('msvs_setup_env()')
+ debug('mssdk_setup_env()')
if env.has_key('MSSDK_DIR'):
sdk_dir = env['MSSDK_DIR']
if sdk_dir is None:
diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py
index ac6e9b3..efe77fa 100644
--- a/src/engine/SCons/Tool/MSCommon/vc.py
+++ b/src/engine/SCons/Tool/MSCommon/vc.py
@@ -45,6 +45,11 @@ import common
debug = common.debug
+import sdk
+
+get_installed_sdks = sdk.get_installed_sdks
+
+
class VisualCException(Exception):
pass
@@ -198,7 +203,11 @@ def find_vc_pdir(msvc_version):
raise MissingConfiguration("registry dir %s not found on the filesystem" % comps)
return None
-def find_batch_file(msvc_version):
+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")
@@ -213,11 +222,21 @@ def find_batch_file(msvc_version):
else: # >= 8
batfilename = os.path.join(pdir, "vcvarsall.bat")
- if os.path.exists(batfilename):
- return batfilename
- else:
+ if not os.path.exists(batfilename):
debug("Not found: %s" % batfilename)
- return None
+ batfilename = None
+
+ installed_sdks=get_installed_sdks()
+ (host_arch,target_arch)=get_host_target(env)
+ for _sdk in installed_sdks:
+ #print "Trying :%s"%_sdk.vc_setup_scripts
+ sdk_bat_file=_sdk.get_sdk_vc_script(host_arch,target_arch)
+ sdk_bat_file_path=os.path.join(pdir,sdk_bat_file)
+ #print "PATH: %s"%sdk_bat_file_path
+ if os.path.exists(sdk_bat_file_path):
+ return (batfilename,sdk_bat_file_path)
+ else:
+ return (batfilename,None)
__INSTALLED_VCS_RUN = None
@@ -319,7 +338,7 @@ def msvc_setup_env(env):
env['MSVS'] = {}
try:
- script = find_batch_file(version)
+ (vc_script,sdk_script) = find_batch_file(env,version)
except VisualCException, e:
msg = str(e)
debug('Caught exception while looking for batch file (%s)' % msg)
@@ -342,13 +361,16 @@ def msvc_setup_env(env):
(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(script), arg))
+ debug('use_script 2 %s, args:%s\n' % (repr(vc_script), arg))
try:
- d = script_env(script, args=arg)
+ d = script_env(vc_script, args=arg)
except BatchFileExecutionError, e:
- msg = "MSVC error while executing %s with args %s (error was %s)" % \
- (script, arg, str(e))
- raise SCons.Errors.UserError(msg)
+ #print "Trying:%s"%sdk_script
+ debug('use_script 3: failed running %s: %s: Error:%s'%(repr(vc_script),arg,e))
+ debug('use_script 4: trying sdk script: %s %s'%(sdk_script,arg))
+ d = script_env(sdk_script,args=[])
+ #return None
+
else:
debug('MSVC_USE_SCRIPT set to False')
warn_msg = "MSVC_USE_SCRIPT set to False, assuming environment " \
diff --git a/src/engine/SCons/compat/_scons_subprocess.py b/src/engine/SCons/compat/_scons_subprocess.py
index 4968825..ccd403a 100644
--- a/src/engine/SCons/compat/_scons_subprocess.py
+++ b/src/engine/SCons/compat/_scons_subprocess.py
@@ -381,7 +381,21 @@ if mswindows:
# can't import it.
pass
import msvcrt
- if 0: # <-- change this to use pywin32 instead of the _subprocess driver
+ try:
+ # Try to get _subprocess
+ from _subprocess import *
+ class STARTUPINFO:
+ dwFlags = 0
+ hStdInput = None
+ hStdOutput = None
+ hStdError = None
+ wShowWindow = 0
+ class pywintypes:
+ error = IOError
+ except ImportError:
+ # If not there, then drop back to requiring pywin32
+ # TODO: Should this be wrapped in try as well? To notify user to install
+ # pywin32 ? With URL to it?
import pywintypes
from win32api import GetStdHandle, STD_INPUT_HANDLE, \
STD_OUTPUT_HANDLE, STD_ERROR_HANDLE
@@ -393,20 +407,8 @@ if mswindows:
GetExitCodeProcess, STARTF_USESTDHANDLES, \
STARTF_USESHOWWINDOW, CREATE_NEW_CONSOLE
from win32event import WaitForSingleObject, INFINITE, WAIT_OBJECT_0
- else:
- # SCons: don't die on Python versions that don't have _subprocess.
- try:
- from _subprocess import *
- except ImportError:
- pass
- class STARTUPINFO:
- dwFlags = 0
- hStdInput = None
- hStdOutput = None
- hStdError = None
- wShowWindow = 0
- class pywintypes:
- error = IOError
+
+
else:
import select
import errno