summaryrefslogtreecommitdiffstats
path: root/SCons
diff options
context:
space:
mode:
Diffstat (limited to 'SCons')
-rw-r--r--SCons/Tool/MSCommon/MSVC/ScriptArguments.py23
-rw-r--r--SCons/Tool/MSCommon/MSVC/ScriptArgumentsTests.py14
-rw-r--r--SCons/Tool/MSCommon/__init__.py1
-rw-r--r--SCons/Tool/MSCommon/vc.py25
-rw-r--r--SCons/Tool/MSCommon/vcTests.py49
5 files changed, 100 insertions, 12 deletions
diff --git a/SCons/Tool/MSCommon/MSVC/ScriptArguments.py b/SCons/Tool/MSCommon/MSVC/ScriptArguments.py
index 1818b93..390e93a 100644
--- a/SCons/Tool/MSCommon/MSVC/ScriptArguments.py
+++ b/SCons/Tool/MSCommon/MSVC/ScriptArguments.py
@@ -764,6 +764,10 @@ def _msvc_script_argument_spectre_constraints(msvc, toolset, spectre_libs, platf
return None
+def _msvc_toolset_version_spectre_path(vc_dir, toolset_version):
+ spectre_dir = os.path.join(vc_dir, "Tools", "MSVC", toolset_version, "lib", "spectre")
+ return spectre_dir
+
def _msvc_script_argument_spectre(env, msvc, vc_dir, toolset, platform_def, arglist):
spectre_libs = env['MSVC_SPECTRE_LIBS']
@@ -780,7 +784,7 @@ def _msvc_script_argument_spectre(env, msvc, vc_dir, toolset, platform_def, argl
raise MSVCArgumentError(err_msg)
if toolset:
- spectre_dir = os.path.join(vc_dir, "Tools", "MSVC", toolset.version, "lib", "spectre")
+ spectre_dir = _msvc_toolset_version_spectre_path(vc_dir, toolset.version)
if not os.path.exists(spectre_dir):
debug(
'spectre libs: msvc_version=%s, toolset_version=%s, spectre_dir=%s',
@@ -992,6 +996,23 @@ def _msvc_toolset_versions_internal(msvc_version, vc_dir, full=True, sxs=False):
return toolset_versions
+def _msvc_toolset_versions_spectre_internal(msvc_version, vc_dir):
+
+ msvc = _msvc_version(msvc_version)
+
+ if len(msvc.vs_def.vc_buildtools_all) <= 1:
+ return None
+
+ _, toolsets_full = _msvc_version_toolsets(msvc, vc_dir)
+
+ spectre_toolset_versions = [
+ toolset_version
+ for toolset_version in toolsets_full
+ if os.path.exists(_msvc_toolset_version_spectre_path(vc_dir, toolset_version))
+ ]
+
+ return spectre_toolset_versions
+
def reset():
debug('')
_reset_have140_cache()
diff --git a/SCons/Tool/MSCommon/MSVC/ScriptArgumentsTests.py b/SCons/Tool/MSCommon/MSVC/ScriptArgumentsTests.py
index 5a5abad..551513e 100644
--- a/SCons/Tool/MSCommon/MSVC/ScriptArgumentsTests.py
+++ b/SCons/Tool/MSCommon/MSVC/ScriptArgumentsTests.py
@@ -136,6 +136,11 @@ class Data:
HAVE_MSVC = True if len(INSTALLED_VERSIONS_PAIRS) else False
+ SPECTRE_TOOLSET_VERSIONS = {
+ version_def.msvc_version: vc.msvc_toolset_versions_spectre(version_def.msvc_version)
+ for version_def, _ in INSTALLED_VERSIONS_PAIRS
+ }
+
SDK_VERSIONS_COMPS_DICT, SDK_VERSIONS_SEEN = _sdk_versions_comps_dict_seen(INSTALLED_VERSIONS_PAIRS)
SDK_VERSIONS_NOTFOUND_DICT = _sdk_versions_notfound(
@@ -406,6 +411,15 @@ class ScriptArgumentsTests(unittest.TestCase):
with self.assertRaises(MSVCSDKVersionNotFound):
_ = func(env, version_def.msvc_version, vc_dir, '')
+ have_spectre = toolset_def.msvc_toolset_version in Data.SPECTRE_TOOLSET_VERSIONS.get(version_def.msvc_version,[])
+ print("HAVE_SPECTRE", have_spectre, version_def.msvc_version, toolset_def.msvc_toolset_version)
+ env = Environment(MSVC_SPECTRE_LIBS=True, MSVC_TOOLSET_VERSION=toolset_def.msvc_toolset_version)
+ if not have_spectre:
+ with self.assertRaises(MSVCSpectreLibsNotFound):
+ _ = func(env, version_def.msvc_version, vc_dir, '')
+ else:
+ _ = func(env, version_def.msvc_version, vc_dir, '')
+
msvc_sdk_version = Data.msvc_sdk_version(version_def.msvc_version)
more_tests = []
diff --git a/SCons/Tool/MSCommon/__init__.py b/SCons/Tool/MSCommon/__init__.py
index 7a65371..c3078ac 100644
--- a/SCons/Tool/MSCommon/__init__.py
+++ b/SCons/Tool/MSCommon/__init__.py
@@ -43,6 +43,7 @@ from SCons.Tool.MSCommon.vc import ( # noqa: F401
msvc_find_vswhere,
msvc_sdk_versions,
msvc_toolset_versions,
+ msvc_toolset_versions_spectre,
msvc_query_version_toolset,
)
diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py
index d19e30a..823ba4b 100644
--- a/SCons/Tool/MSCommon/vc.py
+++ b/SCons/Tool/MSCommon/vc.py
@@ -1384,6 +1384,31 @@ def msvc_toolset_versions(msvc_version=None, full=True, sxs=False):
rval = MSVC.ScriptArguments._msvc_toolset_versions_internal(msvc_version, vc_dir, full=full, sxs=sxs)
return rval
+def msvc_toolset_versions_spectre(msvc_version=None):
+ debug('msvc_version=%s', repr(msvc_version))
+
+ env = None
+ rval = []
+
+ if not msvc_version:
+ msvc_version = msvc_default_version()
+
+ if not msvc_version:
+ debug('no msvc versions detected')
+ return rval
+
+ if msvc_version not in _VCVER:
+ msg = 'Unsupported msvc version {}'.format(repr(msvc_version))
+ raise MSVCArgumentError(msg)
+
+ vc_dir = find_vc_pdir(env, msvc_version)
+ if not vc_dir:
+ debug('VC folder not found for version %s', repr(msvc_version))
+ return rval
+
+ rval = MSVC.ScriptArguments._msvc_toolset_versions_spectre_internal(msvc_version, vc_dir)
+ return rval
+
def msvc_query_version_toolset(version=None, prefer_newest=True):
"""
Returns an msvc version and a toolset version given a version
diff --git a/SCons/Tool/MSCommon/vcTests.py b/SCons/Tool/MSCommon/vcTests.py
index 53b56bc..cd310dd 100644
--- a/SCons/Tool/MSCommon/vcTests.py
+++ b/SCons/Tool/MSCommon/vcTests.py
@@ -243,6 +243,8 @@ class Data:
HAVE_MSVC = True if MSCommon.vc.msvc_default_version() else False
+ INSTALLED_VCS_COMPONENTS = MSCommon.vc.get_installed_vcs_components()
+
@classmethod
def _msvc_toolset_notfound_list(cls, toolset_seen, toolset_list):
new_toolset_list = []
@@ -368,15 +370,6 @@ class MsvcSdkVersionsTests(unittest.TestCase):
class MsvcToolsetVersionsTests(unittest.TestCase):
"""Test msvc_toolset_versions"""
- _installed_vcs_components = None
-
- @classmethod
- def setUpClass(cls):
- cls._installed_vcs_components = MSCommon.vc.get_installed_vcs_components()
-
- def setUp(self):
- self.installed_vcs_components = self.__class__._installed_vcs_components
-
def run_valid_default_msvc(self):
symbol = MSCommon.vc.msvc_default_version()
version_def = MSCommon.msvc_version_components(symbol)
@@ -384,7 +377,7 @@ class MsvcToolsetVersionsTests(unittest.TestCase):
toolset_full_list = MSCommon.vc.msvc_toolset_versions(msvc_version=None, full=True, sxs=False)
toolset_sxs_list = MSCommon.vc.msvc_toolset_versions(msvc_version=None, full=False, sxs=True)
toolset_all_list = MSCommon.vc.msvc_toolset_versions(msvc_version=None, full=True, sxs=True)
- if symbol and version_def in self.installed_vcs_components and version_def.msvc_vernum >= 14.1:
+ if symbol and version_def in Data.INSTALLED_VCS_COMPONENTS and version_def.msvc_vernum >= 14.1:
# sxs list could be empty
self.assertTrue(toolset_full_list, "Toolset full list is empty for msvc version {}".format(repr(None)))
self.assertTrue(toolset_all_list, "Toolset all list is empty for msvc version {}".format(repr(None)))
@@ -408,7 +401,7 @@ class MsvcToolsetVersionsTests(unittest.TestCase):
toolset_full_list = MSCommon.vc.msvc_toolset_versions(msvc_version=symbol, full=True, sxs=False)
toolset_sxs_list = MSCommon.vc.msvc_toolset_versions(msvc_version=symbol, full=False, sxs=True)
toolset_all_list = MSCommon.vc.msvc_toolset_versions(msvc_version=symbol, full=True, sxs=True)
- if version_def in self.installed_vcs_components and version_def.msvc_vernum >= 14.1:
+ if version_def in Data.INSTALLED_VCS_COMPONENTS and version_def.msvc_vernum >= 14.1:
# sxs list could be empty
self.assertTrue(toolset_full_list, "Toolset full list is empty for msvc version {}".format(repr(symbol)))
self.assertTrue(toolset_all_list, "Toolset all list is empty for msvc version {}".format(repr(symbol)))
@@ -423,6 +416,40 @@ class MsvcToolsetVersionsTests(unittest.TestCase):
with self.assertRaises(MSCommon.vc.MSVCArgumentError):
_ = MSCommon.vc.msvc_toolset_versions(msvc_version=symbol)
+class MsvcToolsetVersionsSpectreTests(unittest.TestCase):
+
+ def run_valid_default_msvc(self):
+ symbol = MSCommon.vc.msvc_default_version()
+ version_def = MSCommon.msvc_version_components(symbol)
+ spectre_toolset_list = MSCommon.vc.msvc_toolset_versions_spectre(msvc_version=None)
+ if symbol and version_def in Data.INSTALLED_VCS_COMPONENTS and version_def.msvc_vernum >= 14.1:
+ # spectre toolset list can empty (may not be installed)
+ pass
+ else:
+ self.assertFalse(spectre_toolset_list, "Toolset spectre list is not empty for msvc version {}".format(repr(None)))
+
+ def test_valid_default_msvc(self):
+ if Data.HAVE_MSVC:
+ Patch.MSCommon.vc.msvc_default_version.enable_none()
+ self.run_valid_default_msvc()
+ Patch.MSCommon.vc.msvc_default_version.restore()
+ self.run_valid_default_msvc()
+
+ def test_valid_vcver(self):
+ for symbol in MSCommon.vc._VCVER:
+ version_def = MSCommon.msvc_version_components(symbol)
+ spectre_toolset_list = MSCommon.vc.msvc_toolset_versions_spectre(msvc_version=symbol)
+ if version_def in Data.INSTALLED_VCS_COMPONENTS and version_def.msvc_vernum >= 14.1:
+ # spectre toolset list can empty (may not be installed)
+ pass
+ else:
+ self.assertFalse(spectre_toolset_list, "Toolset spectre list is not empty for msvc version {}".format(repr(symbol)))
+
+ def test_invalid_vcver(self):
+ for symbol in ['12.9', '6.0Exp', '14.3Exp', '99', '14.1Bug']:
+ with self.assertRaises(MSCommon.vc.MSVCArgumentError):
+ _ = MSCommon.vc.msvc_toolset_versions_spectre(msvc_version=symbol)
+
class MsvcQueryVersionToolsetTests(unittest.TestCase):
"""Test msvc_query_toolset_version"""