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):
"""
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
#
# 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',
'x86_64' : [r'lib\x64'],
'ia64' : [r'lib\ia64'],
},
+ vc_setup_scripts = SDk61AndLaterVCSetupScripts,
),
WindowsSDK('6.0A',
'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,
),
]
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:
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:
debug = common.debug
+import sdk
+
+get_installed_sdks = sdk.get_installed_sdks
+
+
class VisualCException(Exception):
pass
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")
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
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)
(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 " \
# 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
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