Skip to content

Commit 84eafe5

Browse files
Merge pull request #20 from secondlife/vstoolset
Fix "Unable to determine a suggested AUTOBUILD_WIN_VSTOOLSET"
2 parents 846e8b5 + 63bdc48 commit 84eafe5

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

autobuild/autobuild_tool_source_environment.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ class SourceEnvError(common.AutobuildError):
2121
_VSxxxCOMNTOOLS_re = re.compile(r"VS(.*)COMNTOOLS$")
2222
_VSxxxCOMNTOOLS_st = "VS%sCOMNTOOLS"
2323

24-
# Map of Visual Studio version to respective default C++ SDK toolset version
24+
# Map of Visual Studio major version to corresponding default C++ SDK toolset version
2525
_VSTOOLSETS = {
26-
"140": "v140", # 2015
27-
"150": "v141", # 2017
28-
"160": "v142", # 2019
29-
"170": "v143", # 2022
26+
"14": "v140", # 2015
27+
"15": "v141", # 2017
28+
"16": "v142", # 2019
29+
"17": "v143", # 2022
3030
}
3131

3232
# From VS 2017 on, we have to look for vswhere.exe at this canonical path to
@@ -755,8 +755,10 @@ def internal_source_environment(configurations, varsfile):
755755
exports["AUTOBUILD_WIN_CMAKE_GEN"] = AUTOBUILD_WIN_CMAKE_GEN
756756

757757
try:
758-
# Provide a suggested C++ SDK version for build scripts to use
759-
exports["AUTOBUILD_WIN_VSTOOLSET"] = os.environ.get("AUTOBUILD_WIN_VSTOOLSET", _VSTOOLSETS[vsver])
758+
# Provide a suggested C++ SDK version for build scripts to
759+
# use. Just as with AUTOBUILD_WIN_CMAKE_GEN above, use only
760+
# the first two digits of vsver to select it.
761+
exports["AUTOBUILD_WIN_VSTOOLSET"] = os.environ.get("AUTOBUILD_WIN_VSTOOLSET", _VSTOOLSETS[vsver[:-1]])
760762
except KeyError:
761763
logger.warning(f"Unable to determine a suggested AUTOBUILD_WIN_VSTOOLSET for vsver {vsver}")
762764

tests/test_source_environment.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,9 @@ def test_config_shorthand(self):
320320

321321
@needs_cygwin
322322
def test_vstoolset_set(self):
323+
# n.b. This test will need to be updated from time to time:
324+
# AUTOBUILD_VSVER is validated against the Visual Studio versions
325+
# installed on the host system.
323326
with envvar("AUTOBUILD_VSVER", "170"):
324327
vars = self.read_variables(self.find_data("empty"))
325328
self.assertEqual(vars["AUTOBUILD_WIN_VSTOOLSET"], "v143")
326-
327-
@needs_cygwin
328-
def test_vstoolset_not_set_if_vsver_unrecognized(self):
329-
with envvar("AUTOBUILD_VSVER", "171"):
330-
vars = self.read_variables(self.find_data("empty"))
331-
self.assertTrue("AUTOBUILD_WIN_VSTOOLSET" not in vars)

0 commit comments

Comments
 (0)