Skip to content

Commit 40e6f1d

Browse files
committed
Fix issue SCons#4543: Add support for msvc toolset versions 14.4x for msvc buildtools v143.
Changes: * Add msvc build series data structure. * Change msvc build tools data structure to contain list of build series. * Update script argument validation and tests.
1 parent 93f887c commit 40e6f1d

File tree

10 files changed

+347
-175
lines changed

10 files changed

+347
-175
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
6363
- The vswhere executable locations for the WinGet and Scoop package managers were
6464
added to the default vswhere executable search list after the Chocolatey
6565
installation location.
66+
- Fix issue #4543: add support for msvc toolset versions 14.4X installed as the
67+
latest msvc toolset versions for msvc buildtools v143. The v143 msvc buildtools
68+
may contain msvc toolset versions from 14.30 to 14.4X.
6669

6770
From Thaddeus Crews:
6871
- GetSConsVersion() to grab the latest SCons version without needing to

RELEASE.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ FIXES
9090
For example, when no vswhere executable is found for the initial detection
9191
and then later an environment is constructed with a user specified vswhere
9292
executable that detects new msvc installations.
93+
- MSVC: Visual Studio 2022 v143 BuildTools now supports msvc toolset versions from
94+
14.30 to 14.4X. Fixes Issue #4543.
9395

9496
IMPROVEMENTS
9597
------------

SCons/Tool/MSCommon/MSVC/Config.py

Lines changed: 99 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -118,50 +118,112 @@
118118
for vc_runtime_alias in vc_runtime_alias_list:
119119
MSVC_RUNTIME_EXTERNAL[vc_runtime_alias] = vc_runtime_def
120120

121-
MSVC_BUILDTOOLS_DEFINITION = namedtuple('MSVCBuildtools', [
122-
'vc_buildtools',
123-
'vc_buildtools_numeric',
121+
MSVC_BUILDSERIES_DEFINITION = namedtuple('MSVCBuildSeries', [
122+
'vc_buildseries',
123+
'vc_buildseries_numeric',
124124
'vc_version',
125125
'vc_version_numeric',
126126
'cl_version',
127127
'cl_version_numeric',
128+
])
129+
130+
MSVC_BUILDSERIES_DEFINITION_LIST = []
131+
132+
MSVC_BUILDSERIES_INTERNAL = {}
133+
MSVC_BUILDSERIES_EXTERNAL = {}
134+
135+
VC_BUILDTOOLS_MAP = {}
136+
137+
VC_VERSION_MAP = {}
138+
CL_VERSION_MAP = {}
139+
140+
for (vc_buildseries, vc_version, cl_version) in [
141+
('144', '14.4', '19.4'),
142+
('143', '14.3', '19.3'),
143+
('142', '14.2', '19.2'),
144+
('141', '14.1', '19.1'),
145+
('140', '14.0', '19.0'),
146+
('120', '12.0', '18.0'),
147+
('110', '11.0', '17.0'),
148+
('100', '10.0', '16.0'),
149+
('90', '9.0', '15.0'),
150+
('80', '8.0', '14.0'),
151+
('71', '7.1', '13.1'),
152+
('70', '7.0', '13.0'),
153+
('60', '6.0', '12.0'),
154+
]:
155+
156+
vc_buildseries_def = MSVC_BUILDSERIES_DEFINITION(
157+
vc_buildseries=vc_buildseries,
158+
vc_buildseries_numeric=int(vc_buildseries),
159+
vc_version=vc_version,
160+
vc_version_numeric=float(vc_version),
161+
cl_version=cl_version,
162+
cl_version_numeric=float(cl_version),
163+
)
164+
165+
MSVC_BUILDSERIES_DEFINITION_LIST.append(vc_buildseries_def)
166+
167+
MSVC_BUILDSERIES_INTERNAL[vc_buildseries] = vc_buildseries_def
168+
MSVC_BUILDSERIES_EXTERNAL[vc_buildseries] = vc_buildseries_def
169+
MSVC_BUILDSERIES_EXTERNAL[vc_version] = vc_buildseries_def
170+
171+
VC_VERSION_MAP[vc_version] = vc_buildseries_def
172+
CL_VERSION_MAP[cl_version] = vc_buildseries_def
173+
174+
MSVC_BUILDTOOLS_DEFINITION = namedtuple('MSVCBuildtools', [
175+
'vc_buildtools',
176+
'vc_buildtools_numeric',
177+
'vc_buildseries_list',
128178
'vc_runtime_def',
129179
'vc_istoolset',
180+
'msvc_version',
181+
'msvc_version_numeric',
130182
])
131183

132184
MSVC_BUILDTOOLS_DEFINITION_LIST = []
133185

134186
MSVC_BUILDTOOLS_INTERNAL = {}
135187
MSVC_BUILDTOOLS_EXTERNAL = {}
136188

137-
VC_VERSION_MAP = {}
138-
139-
for vc_buildtools, vc_version, cl_version, vc_runtime, vc_istoolset in [
140-
('v143', '14.3', '19.3', '140', True),
141-
('v142', '14.2', '19.2', '140', True),
142-
('v141', '14.1', '19.1', '140', True),
143-
('v140', '14.0', '19.0', '140', True),
144-
('v120', '12.0', '18.0', '120', False),
145-
('v110', '11.0', '17.0', '110', False),
146-
('v100', '10.0', '16.0', '100', False),
147-
('v90', '9.0', '15.0', '90', False),
148-
('v80', '8.0', '14.0', '80', False),
149-
('v71', '7.1', '13.1', '71', False),
150-
('v70', '7.0', '13.0', '70', False),
151-
('v60', '6.0', '12.0', '60', False),
189+
MSVC_VERSION_NEWEST = None
190+
MSVC_VERSION_NEWEST_NUMERIC = 0.0
191+
192+
for vc_buildtools, vc_buildseries_list, vc_runtime, vc_istoolset in [
193+
('v143', ['144', '143'], '140', True),
194+
('v142', ['142'], '140', True),
195+
('v141', ['141'], '140', True),
196+
('v140', ['140'], '140', True),
197+
('v120', ['120'], '120', False),
198+
('v110', ['110'], '110', False),
199+
('v100', ['100'], '100', False),
200+
('v90', ['90'], '90', False),
201+
('v80', ['80'], '80', False),
202+
('v71', ['71'], '71', False),
203+
('v70', ['70'], '70', False),
204+
('v60', ['60'], '60', False),
152205
]:
153206

154207
vc_runtime_def = MSVC_RUNTIME_INTERNAL[vc_runtime]
155208

209+
vc_buildseries_list = tuple(
210+
MSVC_BUILDSERIES_INTERNAL[vc_buildseries]
211+
for vc_buildseries in vc_buildseries_list
212+
)
213+
214+
vc_buildtools_numstr = vc_buildtools[1:]
215+
216+
msvc_version = vc_buildtools_numstr[:-1] + '.' + vc_buildtools_numstr[-1]
217+
msvc_version_numeric = float(msvc_version)
218+
156219
vc_buildtools_def = MSVC_BUILDTOOLS_DEFINITION(
157220
vc_buildtools = vc_buildtools,
158221
vc_buildtools_numeric = int(vc_buildtools[1:]),
159-
vc_version = vc_version,
160-
vc_version_numeric = float(vc_version),
161-
cl_version = cl_version,
162-
cl_version_numeric = float(cl_version),
222+
vc_buildseries_list = vc_buildseries_list,
163223
vc_runtime_def = vc_runtime_def,
164224
vc_istoolset = vc_istoolset,
225+
msvc_version = msvc_version,
226+
msvc_version_numeric = msvc_version_numeric,
165227
)
166228

167229
MSVC_BUILDTOOLS_DEFINITION_LIST.append(vc_buildtools_def)
@@ -170,7 +232,12 @@
170232
MSVC_BUILDTOOLS_EXTERNAL[vc_buildtools] = vc_buildtools_def
171233
MSVC_BUILDTOOLS_EXTERNAL[vc_version] = vc_buildtools_def
172234

173-
VC_VERSION_MAP[vc_version] = vc_buildtools_def
235+
for vc_buildseries_def in vc_buildseries_list:
236+
VC_BUILDTOOLS_MAP[vc_buildseries_def.vc_buildseries] = vc_buildtools_def
237+
238+
if vc_buildtools_def.msvc_version_numeric > MSVC_VERSION_NEWEST_NUMERIC:
239+
MSVC_VERSION_NEWEST_NUMERIC = vc_buildtools_def.msvc_version_numeric
240+
MSVC_VERSION_NEWEST = vc_buildtools_def.msvc_version
174241

175242
MSVS_VERSION_INTERNAL = {}
176243
MSVS_VERSION_EXTERNAL = {}
@@ -181,8 +248,6 @@
181248

182249
MSVS_VERSION_MAJOR_MAP = {}
183250

184-
CL_VERSION_MAP = {}
185-
186251
MSVC_SDK_VERSIONS = set()
187252

188253
VISUALSTUDIO_DEFINITION = namedtuple('VisualStudioDefinition', [
@@ -247,15 +312,15 @@
247312

248313
vc_buildtools_def.vc_runtime_def.vc_runtime_vsdef_list.append(vs_def)
249314

250-
vc_version = vc_buildtools_def.vc_version
315+
msvc_version = vc_buildtools_def.msvc_version
251316

252317
MSVS_VERSION_INTERNAL[vs_product] = vs_def
253318
MSVS_VERSION_EXTERNAL[vs_product] = vs_def
254319
MSVS_VERSION_EXTERNAL[vs_version] = vs_def
255320

256-
MSVC_VERSION_INTERNAL[vc_version] = vs_def
321+
MSVC_VERSION_INTERNAL[msvc_version] = vs_def
257322
MSVC_VERSION_EXTERNAL[vs_product] = vs_def
258-
MSVC_VERSION_EXTERNAL[vc_version] = vs_def
323+
MSVC_VERSION_EXTERNAL[msvc_version] = vs_def
259324
MSVC_VERSION_EXTERNAL[vc_buildtools_def.vc_buildtools] = vs_def
260325

261326
if vs_product in VS_PRODUCT_ALIAS:
@@ -264,14 +329,12 @@
264329
MSVS_VERSION_EXTERNAL[vs_product_alias] = vs_def
265330
MSVC_VERSION_EXTERNAL[vs_product_alias] = vs_def
266331

267-
MSVC_VERSION_SUFFIX[vc_version] = vs_def
332+
MSVC_VERSION_SUFFIX[msvc_version] = vs_def
268333
if vs_express:
269-
MSVC_VERSION_SUFFIX[vc_version + 'Exp'] = vs_def
334+
MSVC_VERSION_SUFFIX[msvc_version + 'Exp'] = vs_def
270335

271336
MSVS_VERSION_MAJOR_MAP[vs_version_major] = vs_def
272337

273-
CL_VERSION_MAP[vc_buildtools_def.cl_version] = vs_def
274-
275338
if vc_sdk:
276339
MSVC_SDK_VERSIONS.update(vc_sdk)
277340

@@ -292,7 +355,7 @@
292355
for vs_def in VISUALSTUDIO_DEFINITION_LIST:
293356
if not vs_def.vc_buildtools_def.vc_istoolset:
294357
continue
295-
version_key = vs_def.vc_buildtools_def.vc_version
358+
version_key = vs_def.vc_buildtools_def.msvc_version
296359
MSVC_VERSION_TOOLSET_DEFAULTS_MAP[version_key] = [version_key]
297360
MSVC_VERSION_TOOLSET_SEARCH_MAP[version_key] = []
298361
if vs_def.vs_express:
@@ -305,11 +368,11 @@
305368
for vs_def in VISUALSTUDIO_DEFINITION_LIST:
306369
if not vs_def.vc_buildtools_def.vc_istoolset:
307370
continue
308-
version_key = vs_def.vc_buildtools_def.vc_version
371+
version_key = vs_def.vc_buildtools_def.msvc_version
309372
for vc_buildtools in vs_def.vc_buildtools_all:
310373
toolset_buildtools_def = MSVC_BUILDTOOLS_INTERNAL[vc_buildtools]
311-
toolset_vs_def = MSVC_VERSION_INTERNAL[toolset_buildtools_def.vc_version]
312-
buildtools_key = toolset_buildtools_def.vc_version
374+
toolset_vs_def = MSVC_VERSION_INTERNAL[toolset_buildtools_def.msvc_version]
375+
buildtools_key = toolset_buildtools_def.msvc_version
313376
MSVC_VERSION_TOOLSET_SEARCH_MAP[buildtools_key].extend(MSVC_VERSION_TOOLSET_DEFAULTS_MAP[version_key])
314377

315378
# convert string version set to string version list ranked in descending order

0 commit comments

Comments
 (0)