From a714a848fd6935c305c553347355887c71c0ffdf Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 8 Jan 2019 20:32:07 -0600 Subject: use the vcvars batch script to find installed vc's --- src/engine/SCons/Tool/MSCommon/vc.py | 19 +++++++++---------- src/engine/SCons/Tool/midl.py | 2 +- src/engine/SCons/Tool/mslib.py | 2 +- src/engine/SCons/Tool/mslink.py | 2 +- src/engine/SCons/Tool/msvc.py | 2 +- src/engine/SCons/Tool/msvs.py | 2 +- test/AS/ASFLAGS.py | 2 +- test/AS/ASPPFLAGS.py | 2 +- test/CC/CCFLAGS.py | 2 +- test/CC/CFLAGS.py | 2 +- test/LINK/SHLINKCOMSTR.py | 2 +- test/Libs/LIBPREFIXES.py | 2 +- test/Libs/LIBS.py | 6 ++++-- test/Libs/LIBSUFFIXES.py | 6 +++--- test/Libs/SharedLibraryIxes.py | 2 +- test/long-lines/live.py | 2 +- test/sconsign/script/dblite.py | 2 +- testing/framework/TestSCons.py | 2 +- 18 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index 32ee96f..d3686b0 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -344,16 +344,16 @@ def find_batch_file(env,msvc_version,host_arch,target_arch): __INSTALLED_VCS_RUN = None -def cached_get_installed_vcs(): +def cached_get_installed_vcs(env): global __INSTALLED_VCS_RUN if __INSTALLED_VCS_RUN is None: - ret = get_installed_vcs() + ret = get_installed_vcs(env) __INSTALLED_VCS_RUN = ret return __INSTALLED_VCS_RUN -def get_installed_vcs(): +def get_installed_vcs(env): installed_versions = [] for ver in _VCVER: debug('trying to find VC %s' % ver) @@ -362,11 +362,10 @@ def get_installed_vcs(): if VC_DIR: debug('found VC %s' % ver) # check to see if the x86 or 64 bit compiler is in the bin dir - if (os.path.exists(os.path.join(VC_DIR, r'bin\cl.exe')) - or os.path.exists(os.path.join(VC_DIR, r'bin\amd64\cl.exe'))): + if msvc_find_valid_batch_script(env,ver): installed_versions.append(ver) else: - debug('find_vc_pdir no cl.exe found %s' % ver) + debug('find_vc_pdir no vcvars script found %s' % ver) else: debug('find_vc_pdir return None for ver %s' % ver) except VisualCException as e: @@ -423,7 +422,7 @@ def get_default_version(env): % (msvc_version, msvs_version)) return msvs_version if not msvc_version: - installed_vcs = cached_get_installed_vcs() + installed_vcs = cached_get_installed_vcs(env) debug('installed_vcs:%s' % installed_vcs) if not installed_vcs: #msg = 'No installed VCs' @@ -500,7 +499,7 @@ def msvc_find_valid_batch_script(env,version): 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()) + warn_msg = warn_msg % (version, cached_get_installed_vcs(env)) SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) continue @@ -579,8 +578,8 @@ def msvc_setup_env(env): SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, "Could not find MSVC compiler 'cl.exe', it may need to be installed separately with Visual Studio") -def msvc_exists(version=None): - vcs = cached_get_installed_vcs() +def msvc_exists(env, version=None): + vcs = cached_get_installed_vcs(env) if version is None: return len(vcs) > 0 return version in vcs diff --git a/src/engine/SCons/Tool/midl.py b/src/engine/SCons/Tool/midl.py index ed9ea94..2757c34 100644 --- a/src/engine/SCons/Tool/midl.py +++ b/src/engine/SCons/Tool/midl.py @@ -79,7 +79,7 @@ def generate(env): env['BUILDERS']['TypeLibrary'] = midl_builder def exists(env): - return msvc_exists() + return msvc_exists(env) # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/mslib.py b/src/engine/SCons/Tool/mslib.py index c5a7a32..c901a75 100644 --- a/src/engine/SCons/Tool/mslib.py +++ b/src/engine/SCons/Tool/mslib.py @@ -55,7 +55,7 @@ def generate(env): env['LIBSUFFIX'] = '.lib' def exists(env): - return msvc_exists() + return msvc_exists(env) # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py index 55cf33f..c8b00d2 100644 --- a/src/engine/SCons/Tool/mslink.py +++ b/src/engine/SCons/Tool/mslink.py @@ -328,7 +328,7 @@ def generate(env): env['LDMODULECOM'] = compositeLdmodAction def exists(env): - return msvc_exists() + return msvc_exists(env) # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py index 1412cf7..9f3c1fa 100644 --- a/src/engine/SCons/Tool/msvc.py +++ b/src/engine/SCons/Tool/msvc.py @@ -289,7 +289,7 @@ def generate(env): env['ENV']['SystemRoot'] = SCons.Platform.win32.get_system_root() def exists(env): - return msvc_exists() + return msvc_exists(env) # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 62f27f2..4b73a3b 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -1990,7 +1990,7 @@ def generate(env): env['SCONS_HOME'] = os.environ.get('SCONS_HOME') def exists(env): - return msvc_exists() + return msvc_exists(env) # Local Variables: # tab-width:4 diff --git a/test/AS/ASFLAGS.py b/test/AS/ASFLAGS.py index 79fde8c..b72d32d 100644 --- a/test/AS/ASFLAGS.py +++ b/test/AS/ASFLAGS.py @@ -42,7 +42,7 @@ o_c = ' -x -c' if sys.platform == 'win32': import SCons.Tool.MSCommon as msc - if msc.msvc_exists(): + if msc.msvc_exists(test.Environment()): o_c = ' -x' test.write('SConstruct', """ diff --git a/test/AS/ASPPFLAGS.py b/test/AS/ASPPFLAGS.py index 254a458..d548eaa 100644 --- a/test/AS/ASPPFLAGS.py +++ b/test/AS/ASPPFLAGS.py @@ -42,7 +42,7 @@ o_c = ' -x -c' if sys.platform == 'win32': import SCons.Tool.MSCommon as msc - if msc.msvc_exists(): + if msc.msvc_exists(test.Environment()): o_c = ' -x' test.write('SConstruct', """ diff --git a/test/CC/CCFLAGS.py b/test/CC/CCFLAGS.py index 069b429..967f865 100644 --- a/test/CC/CCFLAGS.py +++ b/test/CC/CCFLAGS.py @@ -32,7 +32,7 @@ _obj = TestSCons._obj if sys.platform == 'win32': import SCons.Tool.MSCommon as msc - if not msc.msvc_exists(): + if not msc.msvc_exists(test.Environment()): fooflags = '-DFOO' barflags = '-DBAR' else: diff --git a/test/CC/CFLAGS.py b/test/CC/CFLAGS.py index 590d6b5..6d0ee39 100644 --- a/test/CC/CFLAGS.py +++ b/test/CC/CFLAGS.py @@ -47,7 +47,7 @@ _obj = TestSCons._obj if sys.platform == 'win32': import SCons.Tool.MSCommon as msc - if not msc.msvc_exists(): + if not msc.msvc_exists(test.Environment()): fooflags = '-DFOO' barflags = '-DBAR' else: diff --git a/test/LINK/SHLINKCOMSTR.py b/test/LINK/SHLINKCOMSTR.py index 4dd5c7c..bf419e5 100644 --- a/test/LINK/SHLINKCOMSTR.py +++ b/test/LINK/SHLINKCOMSTR.py @@ -73,7 +73,7 @@ test.must_match('test3.dll', "test1.c\ntest2.c\n") if sys.platform == "win32": import SCons.Tool.MSCommon as msc - if msc.msvc_exists(): + if msc.msvc_exists(test.Environment()): # Now test an actual compile and link. Since MS Windows # resets the link actions, this could fail even if the above # test passed. diff --git a/test/Libs/LIBPREFIXES.py b/test/Libs/LIBPREFIXES.py index aed451e..b9621a1 100644 --- a/test/Libs/LIBPREFIXES.py +++ b/test/Libs/LIBPREFIXES.py @@ -31,7 +31,7 @@ import TestSCons if sys.platform == 'win32': _lib = '.lib' import SCons.Tool.MSCommon as msc - if not msc.msvc_exists(): + if not msc.msvc_exists(test.Environment()): _lib = '.a' else: _lib = '.a' diff --git a/test/Libs/LIBS.py b/test/Libs/LIBS.py index 5639228..0798475 100644 --- a/test/Libs/LIBS.py +++ b/test/Libs/LIBS.py @@ -27,17 +27,19 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons import sys +test = TestSCons.TestSCons() + if sys.platform == 'win32': _exe = '.exe' bar_lib = 'bar.lib' import SCons.Tool.MSCommon as msc - if not msc.msvc_exists(): + if not msc.msvc_exists(test.Environment()): bar_lib = 'libbar.a' else: _exe = '' bar_lib = 'libbar.a' -test = TestSCons.TestSCons() + test.subdir('sub1', 'sub2') diff --git a/test/Libs/LIBSUFFIXES.py b/test/Libs/LIBSUFFIXES.py index 13baeab..030e601 100644 --- a/test/Libs/LIBSUFFIXES.py +++ b/test/Libs/LIBSUFFIXES.py @@ -28,16 +28,16 @@ import os import sys import TestSCons +test = TestSCons.TestSCons() + if sys.platform == 'win32': lib_ = '' import SCons.Tool.MSCommon as msc - if not msc.msvc_exists(): + if not msc.msvc_exists(test.Environment()): lib_ = 'lib' else: lib_ = 'lib' -test = TestSCons.TestSCons() - test.write('SConstruct', """ env = Environment(LIBSUFFIX = '.xxx', LIBSUFFIXES = ['.xxx']) diff --git a/test/Libs/SharedLibraryIxes.py b/test/Libs/SharedLibraryIxes.py index 93d67ea..2a58026 100644 --- a/test/Libs/SharedLibraryIxes.py +++ b/test/Libs/SharedLibraryIxes.py @@ -42,7 +42,7 @@ isWindows = sys.platform == 'win32' isMingw = False if isWindows: import SCons.Tool.MSCommon as msc - if not msc.msvc_exists(): + if not msc.msvc_exists(test.Environment()): # We can't seem to find any MSVC version, so we assume # that MinGW is installed instead. Accordingly, we use the # standard gcc/g++ conventions for lib prefixes and suffixes diff --git a/test/long-lines/live.py b/test/long-lines/live.py index 5618f55..8540cd7 100644 --- a/test/long-lines/live.py +++ b/test/long-lines/live.py @@ -43,7 +43,7 @@ if sys.platform == 'win32': linkflag_init = '/LIBPATH:' + test.workpath() linkflag = ' /LIBPATH:' + test.workpath() import SCons.Tool.MSCommon as msc - if not msc.msvc_exists(): + if not msc.msvc_exists(test.Environment()): lib_shared_dll = 'shared.dll' lib_static_lib = 'libstatic.a' arflag_init = 'r' diff --git a/test/sconsign/script/dblite.py b/test/sconsign/script/dblite.py index 0daf8bf..36718f1 100644 --- a/test/sconsign/script/dblite.py +++ b/test/sconsign/script/dblite.py @@ -114,7 +114,7 @@ date_re = r'\S+ \S+ [ \d]\d \d\d:\d\d:\d\d \d\d\d\d' if sys.platform == 'win32': import SCons.Tool.MSCommon as msc - if msc.msvc_exists(): + if msc.msvc_exists(test.Environment()): manifest = r""" embedManifestExeCheck\(target, source, env\)""" else: diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index b543c07..01002c5 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -1072,7 +1072,7 @@ SConscript( sconscript ) try: import SCons.Tool.MSCommon as msc - if not msc.msvc_exists(): + if not msc.msvc_exists(self.Environment()): msg = "No MSVC toolchain found...skipping test\n" self.skip_test(msg) except: -- cgit v0.12