From 68e4fe5ac49effe8959bc8532584edf04553c931 Mon Sep 17 00:00:00 2001 From: Luca Falavigna Date: Wed, 10 Mar 2010 14:14:26 +0100 Subject: Imported Upstream version 1.2.0.d20100306 --- src/engine/SCons/Tool/MSCommon/vc.py | 66 ++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 15 deletions(-) (limited to 'src/engine/SCons/Tool/MSCommon/vc.py') diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index a190b8e..f2f2a01 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -30,7 +30,7 @@ # * test on 64 bits XP + VS 2005 (and VS 6 if possible) # * SDK # * Assembly -__revision__ = "src/engine/SCons/Tool/MSCommon/vc.py 4629 2010/01/17 22:23:21 scons" +__revision__ = "src/engine/SCons/Tool/MSCommon/vc.py 4691 2010/03/06 16:22:36 bdbaddog" __doc__ = """Module for Visual C/C++ detection and configuration. """ @@ -45,6 +45,11 @@ import common debug = common.debug +import sdk + +get_installed_sdks = sdk.get_installed_sdks + + class VisualCException(Exception): pass @@ -198,10 +203,16 @@ 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") + + debug('vc.py: find_batch_file() pdir:%s'%pdir) vernum = float(msvc_version) if 7 <= vernum < 8: @@ -213,11 +224,22 @@ 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: + 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 @@ -319,7 +341,8 @@ def msvc_setup_env(env): env['MSVS'] = {} try: - script = find_batch_file(version) + (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) @@ -329,7 +352,8 @@ def msvc_setup_env(env): 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)) @@ -342,13 +366,24 @@ 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)) - try: - d = script_env(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) + 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 " \ @@ -357,6 +392,7 @@ def msvc_setup_env(env): 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): -- cgit v1.2.3