summaryrefslogtreecommitdiffstats
path: root/SCons/Tool/msvc.xml
blob: c6fa977723d977225475f7a8453b390c815d825f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
<?xml version="1.0"?>
<!--
SPDX-FileCopyrightText: Copyright The SCons Foundation (https://scons.org)
SPDX-License-Identifier: MIT
SPDX-FileType: DOCUMENTATION

This file is processed by the bin/SConsDoc.py module.
-->

<!DOCTYPE sconsdoc [
<!ENTITY % scons SYSTEM '../../doc/scons.mod'>
%scons;
<!ENTITY % builders-mod SYSTEM '../../doc/generated/builders.mod'>
%builders-mod;
<!ENTITY % functions-mod SYSTEM '../../doc/generated/functions.mod'>
%functions-mod;
<!ENTITY % tools-mod SYSTEM '../../doc/generated/tools.mod'>
%tools-mod;
<!ENTITY % variables-mod SYSTEM '../../doc/generated/variables.mod'>
%variables-mod;
]>

<sconsdoc xmlns="http://www.scons.org/dbxsd/v1.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd">

<tool name="msvc">
<summary>
<para>
Sets &consvars; for the &MSVC; compiler.
</para>
</summary>
<sets>
<item>CCDEPFLAGS</item>
<item>CCPDBFLAGS</item>
<item>CCPCHFLAGS</item>
<item><!--CCCOMFLAGS--></item>
<item>CC</item>
<item>CCFLAGS</item>
<item>CFLAGS</item>
<item>CCCOM</item>
<item>SHCC</item>
<item>SHCCFLAGS</item>
<item>SHCFLAGS</item>
<item>SHCCCOM</item>
<item>CXX</item>
<item>CXXFLAGS</item>
<item>CXXCOM</item>
<item>SHCXX</item>
<item>SHCXXFLAGS</item>
<item>SHCXXCOM</item>
<item>CPPDEFPREFIX</item>
<item>CPPDEFSUFFIX</item>
<item>INCPREFIX</item>
<item>INCSUFFIX</item>
<item><!--STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME--></item>
<item>RC</item>
<item>RCFLAGS</item>
<item>RCCOM</item>
<item>BUILDERS</item>
<item>OBJPREFIX</item>
<item>OBJSUFFIX</item>
<item>SHOBJPREFIX</item>
<item>SHOBJSUFFIX</item>
<item>CFILESUFFIX</item>
<item>CXXFILESUFFIX</item>
<item>PCHPDBFLAGS</item>
<item>PCHCOM</item>
</sets>
<uses>
<item>CCCOMSTR</item>
<item>SHCCCOMSTR</item>
<item>CXXCOMSTR</item>
<item>SHCXXCOMSTR</item>
<item>PCH</item>
<item>PCHSTOP</item>
<item>PDB</item>
<item>MSVC_VERSION</item>
<item>MSVC_USE_SCRIPT</item>
<item>MSVC_USE_SCRIPT_ARGS</item>
<item>MSVC_USE_SETTINGS</item>
<item>MSVC_NOTFOUND_POLICY</item>
<item>MSVC_SCRIPTERROR_POLICY</item>
<item>MSVC_SCRIPT_ARGS</item>
<item>MSVC_SDK_VERSION</item>
<item>MSVC_TOOLSET_VERSION</item>
<item>MSVC_SPECTRE_LIBS</item>

</uses>
</tool>

<builder name="PCH">
<summary>
<para>
Builds a &MSVC; precompiled header.
Calling this builder
returns a list of two target nodes: the PCH as the first element,
and the object file as the second element.
Normally the object file is ignored.
The &b-PCH; builder is generally used in
conjunction with the &cv-link-PCH; &consvar; to force object files to use
the precompiled header:
</para>

<example_commands>
env['PCH'] = env.PCH('StdAfx.cpp')[0]
</example_commands>

<note>
<para>
This builder is specific to the PCH implementation in  &MSVC;.
Other compiler chains also implement precompiled header support,
but &b-PCH; does not work with them at this time.
As a result, the builder is only generated into the
construction environment when
&MSVC; is being used as the compiler.
</para>
<para>
The builder only works correctly in a C++ project.
The Microsoft implementation distinguishes between
precompiled headers from C and C++.
Use of the builder will cause the PCH generation to happen with a flag
that tells <application>cl.exe</application> all of the
files are C++ files; if that PCH file is then supplied when
compiling a C source file,
<application>cl.exe</application> will fail the build with
a compatibility violation.
</para>
<para>
If possible, arrange the project so that a
C++ source file passed to the &b-PCH; builder
is not also included in the list of sources
to be otherwise compiled in the project.
&SCons; will correctly track that file in the dependency tree
as a result of the &b-PCH; call,
and (for MSVC 11.0 and greater) automatically add the
corresponding object file to the link line.
If the source list is automatically generated,
for example using the &f-link-Glob; function,
it may be necessary to remove that file from the list.
</para>
</note>
</summary>
</builder>

<builder name="RES">
<summary>
<para>
Builds a &MSVC; resource file.
This builder method is only provided
when &MSVC; or MinGW is being used as the compiler. The
<filename>.res</filename>
(or
<filename>.o</filename>
for MinGW) suffix is added to the target name if no other suffix is given.
The source
file is scanned for implicit dependencies as though it were a C file.
Example:
</para>

<example_commands>
env.RES('resource.rc')
</example_commands>
</summary>
</builder>

<cvar name="CCPCHFLAGS">
<summary>
<para>
Options added to the compiler command line
to support building with precompiled headers.
The default value expands expands to the appropriate
&MSVC; command-line options
when the &cv-link-PCH; &consvar; is set.
</para>
</summary>
</cvar>

<cvar name="CCPDBFLAGS">
<summary>
<para>
Options added to the compiler command line
to support storing debugging information in a
&MSVC; PDB file.
The default value expands expands to appropriate
&MSVC; command-line options
when the &cv-link-PDB; &consvar; is set.
</para>

<para>
The &MSVC; compiler option that &SCons; uses by default
to generate PDB information is <option>/Z7</option>.
This works correctly with parallel (<option>-j</option>) builds
because it embeds the debug information in the intermediate object files,
as opposed to sharing a single PDB file between multiple object files.
This is also the only way to get debug information
embedded into a static library.
Using the <option>/Zi</option> instead may yield improved
link-time performance,
although parallel builds will no longer work.
</para>

<para>
You can generate PDB files with the <option>/Zi</option>
switch by overriding the default &cv-link-CCPDBFLAGS; variable as follows:
</para>

<example_commands>
env['CCPDBFLAGS'] = ['${(PDB and "/Zi /Fd%s" % File(PDB)) or ""}']
</example_commands>

<para>
An alternative would be to use the <option>/Zi</option>
to put the debugging information in a separate <filename>.pdb</filename>
file for each object file by overriding
the &cv-link-CCPDBFLAGS; variable as follows:
</para>

<example_commands>
env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb'
</example_commands>
</summary>
</cvar>

<cvar name="MSVC_BATCH">
<summary>
<para>
When set to any true value,
specifies that &SCons; should batch
compilation of object files
when calling the &MSVC; compiler.
All compilations of source files from the same source directory
that generate target files in a same output directory
and were configured in &SCons; using the same &consenv;
will be built in a single call to the compiler.
Only source files that have changed since their
object files were built will be passed to each compiler invocation
(via the &cv-link-CHANGED_SOURCES; &consvar;).
Any compilations where the object (target) file base name
(minus the <filename>.obj</filename>)
does not match the source file base name
will be compiled separately.
</para>
</summary>
</cvar>

<cvar name="PCH">
<summary>
<para>
A node for the &MSVC; precompiled header that will be
used when compiling object files.
This variable is ignored by tools other than &MSVC;.
When this variable is
defined, &SCons; will add options to the compiler command line to
cause it to use the precompiled header, and will also set up the
dependencies for the PCH file.
Examples:
</para>

<example_commands>
env['PCH'] = File('StdAfx.pch')
env['PCH'] = env.PCH('pch.cc')[0]
</example_commands>
</summary>
</cvar>

<cvar name="PCHCOM">
<summary>
<para>
The command line used by the
&b-link-PCH;
builder to generated a precompiled header.
</para>
</summary>
</cvar>

<cvar name="PCHCOMSTR">
<summary>
<para>
The string displayed when generating a precompiled header.
If not set, then &cv-link-PCHCOM; (the command line) is displayed.
</para>
</summary>
</cvar>

<cvar name="PCHPDBFLAGS">
<summary>
<para>
A &consvar; that, when expanded,
adds the <option>/yD</option> flag to the command line
only if the &cv-link-PDB; &consvar; is set.
</para>
</summary>
</cvar>

<cvar name="PCHSTOP">
<summary>
<para>
This variable specifies how much of a source file is precompiled. This
variable is ignored by tools other than &MSVC;, or when
the PCH variable is not being used. When this variable is defined, it
must be a string that is the name of the header that
is included at the end of the precompiled portion of the source files, or
the empty string if the "#pragma hrdstop" construct is being used:
</para>

<example_commands>
env['PCHSTOP'] = 'StdAfx.h'
</example_commands>
</summary>
</cvar>

<cvar name="RC">
<summary>
<para>
The resource compiler used to build
a &MSVC; resource file.
</para>
</summary>
</cvar>

<cvar name="RCCOM">
<summary>
<para>
The command line used to build
a &MSVC; resource file.
</para>
</summary>
</cvar>

<cvar name="RCCOMSTR">
<summary>
<para>
The string displayed when invoking the resource compiler
to build a &MSVC; resource file.
If this is not set, then &cv-link-RCCOM; (the command line) is displayed.
</para>
</summary>
</cvar>

<cvar name="RCFLAGS">
<summary>
<para>
The flags passed to the resource compiler by the &b-link-RES; builder.
</para>
</summary>
</cvar>

<cvar name="RCINCFLAGS">
<summary>
<para>
An automatically-generated &consvar;
containing the command-line options
for specifying directories to be searched
by the resource compiler.
The value of &cv-RCINCFLAGS; is created
by respectively prepending and appending
&cv-link-RCINCPREFIX; and &cv-link-RCINCSUFFIX;
to the beginning and end
of each directory in &cv-link-CPPPATH;.
</para>
</summary>
</cvar>

<cvar name="RCINCPREFIX">
<summary>
<para>
The prefix (flag) used to specify an include directory
on the resource compiler command line.
This will be prepended to the beginning of each directory
in the &cv-link-CPPPATH; &consvar;
when the &cv-link-RCINCFLAGS; variable is expanded.
</para>
</summary>
</cvar>

<cvar name="RCINCSUFFIX">
<summary>
<para>
The suffix used to specify an include directory
on the resource compiler command line.
This will be appended to the end of each directory
in the &cv-link-CPPPATH; &consvar;
when the &cv-link-RCINCFLAGS; variable is expanded.
</para>
</summary>
</cvar>

<cvar name="MSVC_VERSION">
<summary>
<para>
A string to select the preferred  version of &MSVC;.
If the specified version is unavailable and/or unknown to &SCons;,
a warning is issued showing the versions actually discovered,
and the build will eventually fail indicating a missing compiler binary.
If &cv-MSVC_VERSION; is not set, &SCons; will (by default) select the
latest version of &MSVC; installed on your system
(excluding any preview versions).
</para>

<note>
  <para>
    In order to take effect, &cv-MSVC_VERSION; must be set before
    the initial &MSVC; compiler discovery takes place.
    Discovery happens, at the latest, during the first call to the
    &f-link-Environment; function, unless a <parameter>tools</parameter>
    list is specified which excludes the entire &MSVC; toolchain -
    that is, omits <literal>"defaults"</literal>
    and any specific tool module that refers to parts of the toolchain
    (&t-link-msvc;, &t-link-mslink;, &t-link-masm;, &t-link-midl;
    and &t-link-msvs;). In this case, detection is deferred until
    any one of those tool modules is invoked manually.
    The following two examples illustrate this:
  </para>

  <programlisting>
# MSVC_VERSION set as Environment is created
env = Environment(MSVC_VERSION='14.2')

# Initialization deferred with empty tools, triggered manually
env = Environment(tools=[])
env['MSVC_VERSION'] = '14.2
env.Tool('msvc')
env.Tool('mslink')
env.Tool('msvs')
  </programlisting>
</note>

<para>
The valid values for &cv-MSVC_VERSION; represent major versions
of the compiler, except that versions ending in <literal>Exp</literal>
refer to "Express" or "Express for Desktop" Visual Studio editions.
Values that do not look like a valid compiler version
<emphasis>string</emphasis> are not supported.
</para>

<para>
The following table shows the correspondence
of &cv-MSVC_VERSION; values to various version indicators
('x' is used as a placeholder for
a single digit that can vary).
</para>

<informaltable>
  <tgroup cols="5">
    <colspec align="left" />
    <colspec align="center" />
    <colspec align="center" />
    <colspec align="left" />
    <colspec align="center" />
    <thead>
      <row>
        <entry> SCons Key </entry>
        <entry> <literallayout>
Visual C++
Version </literallayout></entry>
        <entry> <literal>_MSVC_VER</literal> </entry>
        <entry> Visual Studio Product </entry>
        <!--entry> <literallayout>
Visual Studio
Product </literallayout></entry-->
        <entry> <literallayout>
MSBuild /
Visual Studio </literallayout></entry>
      </row>
    </thead>
    <tbody>
      <row>
        <entry> <literal>"14.3"</literal> </entry>
        <entry> 14.3x </entry>
        <entry> 193x </entry>
        <entry> Visual Studio 2022 </entry>
        <entry> 17.x, 17.1x </entry>
      </row>
      <row>
        <entry> <literal>"14.2"</literal> </entry>
        <entry> 14.2x </entry>
        <entry> 192x </entry>
        <entry> Visual Studio 2019 </entry>
        <entry> 16.x, 16.1x </entry>
      </row>
      <row>
        <entry> <literal>"14.1"</literal> </entry>
        <entry> 14.1 or 14.1x </entry>
        <entry> 191x </entry>
        <entry> Visual Studio 2017 </entry>
        <entry> 15.x </entry>
      </row>
      <row>
        <entry> <literal>"14.1Exp"</literal> </entry>
        <entry> 14.1 or 14.1x </entry>
        <entry> 191x </entry>
        <entry> Visual Studio 2017 Express </entry>
        <entry> 15.x </entry>
      </row>
      <row>
        <entry> <literal>"14.0"</literal> </entry>
        <entry> 14.0 </entry>
        <entry> 1900 </entry>
        <entry> Visual Studio 2015 </entry>
        <entry> 14.0 </entry>
      </row>
      <row>
        <entry> <literal>"14.0Exp"</literal> </entry>
        <entry> 14.0 </entry>
        <entry> 1900 </entry>
        <entry> Visual Studio 2015 Express </entry>
        <entry> 14.0 </entry>
      </row>
      <row>
        <entry> <literal>"12.0"</literal> </entry>
        <entry> 12.0 </entry>
        <entry> 1800 </entry>
        <entry> Visual Studio 2013 </entry>
        <entry> 12.0 </entry>
      </row>
      <row>
        <entry> <literal>"12.0Exp"</literal> </entry>
        <entry> 12.0 </entry>
        <entry> 1800 </entry>
        <entry> Visual Studio 2013 Express </entry>
        <entry> 12.0 </entry>
      </row>
      <row>
        <entry> <literal>"11.0"</literal> </entry>
        <entry> 11.0 </entry>
        <entry> 1700 </entry>
        <entry> Visual Studio 2012 </entry>
        <entry> 11.0 </entry>
      </row>
      <row>
        <entry> <literal>"11.0Exp"</literal> </entry>
        <entry> 11.0 </entry>
        <entry> 1700 </entry>
        <entry> Visual Studio 2012 Express </entry>
        <entry> 11.0 </entry>
      </row>
      <row>
        <entry> <literal>"10.0"</literal> </entry>
        <entry> 10.0 </entry>
        <entry> 1600 </entry>
        <entry> Visual Studio 2010 </entry>
        <entry> 10.0 </entry>
      </row>
      <row>
        <entry> <literal>"10.0Exp"</literal> </entry>
        <entry> 10.0 </entry>
        <entry> 1600 </entry>
        <entry> Visual C++ Express 2010 </entry>
        <entry> 10.0 </entry>
      </row>
      <row>
        <entry> <literal>"9.0"</literal> </entry>
        <entry> 9.0 </entry>
        <entry> 1500 </entry>
        <entry> Visual Studio 2008 </entry>
        <entry> 9.0 </entry>
      </row>
      <row>
        <entry> <literal>"9.0Exp"</literal> </entry>
        <entry> 9.0 </entry>
        <entry> 1500 </entry>
        <entry> Visual C++ Express 2008 </entry>
        <entry> 9.0 </entry>
      </row>
      <row>
        <entry> <literal>"8.0"</literal> </entry>
        <entry> 8.0 </entry>
        <entry> 1400 </entry>
        <entry> Visual Studio 2005 </entry>
        <entry> 8.0 </entry>
      </row>
      <row>
        <entry> <literal>"8.0Exp"</literal> </entry>
        <entry> 8.0 </entry>
        <entry> 1400 </entry>
        <entry> Visual C++ Express 2005 </entry>
        <entry> 8.0 </entry>
      </row>
      <row>
        <entry> <literal>"7.1"</literal> </entry>
        <entry> 7.1 </entry>
        <entry> 1300 </entry>
        <entry> Visual Studio .NET 2003 </entry>
        <entry> 7.1 </entry>
      </row>
      <row>
        <entry> <literal>"7.0"</literal> </entry>
        <entry> 7.0 </entry>
        <entry> 1200 </entry>
        <entry> Visual Studio .NET 2002 </entry>
        <entry> 7.0 </entry>
      </row>
      <row>
        <entry> <literal>"6.0"</literal> </entry>
        <entry> 6.0 </entry>
        <entry> 1100 </entry>
        <entry> Visual Studio 6.0 </entry>
        <entry> 6.0 </entry>
      </row>
    </tbody>
  </tgroup>
</informaltable>

<note>
  <itemizedlist>

    <listitem><para>
    It is not necessary to install a Visual Studio IDE
    to build with &SCons; (for example, you can install only
    Build Tools), but when a Visual Studio IDE is installed,
    additional builders such as &b-link-MSVSSolution; and
    &b-link-MSVSProject; become available and correspond to
    the specified versions.
    </para></listitem>

    <listitem><para>
    Versions ending in <literal>Exp</literal> refer to historical
    "Express" or "Express for Desktop" Visual Studio editions,
    which had feature limitations compared to the full editions.
    It is only necessary to specify the <literal>Exp</literal>
    suffix to select the express edition when both express and
    non-express editions of the same product are installed
    simultaneously. The <literal>Exp</literal> suffix is unnecessary,
    but accepted, when only the express edition is installed.
    </para></listitem>
  </itemizedlist>
</note>

<para>
The compilation environment can be further or more precisely specified through the
use of several other &consvars;: see the descriptions of
&cv-link-MSVC_TOOLSET_VERSION;,
&cv-link-MSVC_SDK_VERSION;,
&cv-link-MSVC_USE_SCRIPT;,
&cv-link-MSVC_USE_SCRIPT_ARGS;,
and &cv-link-MSVC_USE_SETTINGS;.
</para>

</summary>
</cvar>

<cvar name="MSVC_USE_SCRIPT">
<summary>
<para>
Use a batch script to set up the &MSVC; compiler.
</para>

<para>
If set to the name of a Visual Studio <filename>.bat</filename> file
(e.g. <filename>vcvars.bat</filename>),
&SCons; will run that batch file instead of the auto-detected one,
and extract the relevant variables from the result (typically
<envar>%INCLUDE%</envar>,
<envar>%LIB%</envar>, and
<envar>%PATH%</envar>) for supplying to the build.
This can be useful to force the use of a compiler version that
&SCons; does not detect.
&cv-link-MSVC_USE_SCRIPT_ARGS; provides arguments passed to this script.
</para>

<para>
Setting
&cv-MSVC_USE_SCRIPT; to <constant>None</constant> bypasses the
Visual Studio autodetection entirely;
use this if you are running &SCons; in a Visual Studio <command>cmd</command>
window and importing the shell's environment variables - that
is, if you are sure everything is set correctly already and
you don't want &SCons; to change anything.
</para>
<para>
&cv-MSVC_USE_SCRIPT; ignores &cv-link-MSVC_VERSION; and &cv-link-TARGET_ARCH;.
</para>

<para><emphasis>Changed in version 4.4:</emphasis>
new &cv-link-MSVC_USE_SCRIPT_ARGS; provides a
way to pass arguments.
</para>

</summary>
</cvar>

<cvar name="MSVC_USE_SCRIPT_ARGS">
<summary>
<para>
Provides arguments passed to the script &cv-link-MSVC_USE_SCRIPT;.
</para>

<para><emphasis>New in version 4.4</emphasis></para>

</summary>
</cvar>

<cvar name="MSVC_USE_SETTINGS">
<summary>
<para>
Use a dictionary to set up the &MSVC; compiler.
</para>

<para>
&cv-MSVC_USE_SETTINGS; is ignored when &cv-link-MSVC_USE_SCRIPT; is defined
and/or when &cv-MSVC_USE_SETTINGS; is set to <constant>None</constant>.
</para>

<para>
The dictionary is used to populate the environment with the relevant variables
(typically <envar>%INCLUDE%</envar>, <envar>%LIB%</envar>, and <envar>%PATH%</envar>)
for supplying to the build. This can be useful to force the use of a compiler environment
that &SCons; does not configure correctly. This is an alternative to manually configuring
the environment when bypassing Visual Studio autodetection entirely by setting
&cv-link-MSVC_USE_SCRIPT; to <constant>None</constant>.
</para>

<para>
Here is an example of configuring a build environment using the &MSVC; compiler
included in the Microsoft SDK on a 64-bit host and building for a 64-bit architecture:
<programlisting>
# Microsoft SDK 6.0 (MSVC 8.0): 64-bit host and 64-bit target
msvc_use_settings = {
    "PATH": [
        "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0\\VC\\Bin\\x64",
        "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0\\Bin\\x64",
        "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0\\Bin",
        "C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727",
        "C:\\Windows\\system32",
        "C:\\Windows",
        "C:\\Windows\\System32\\Wbem",
        "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\"
    ],
    "INCLUDE": [
        "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0\\VC\\Include",
        "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0\\VC\\Include\\Sys",
        "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0\\Include",
        "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0\\Include\\gl",
    ],
    "LIB": [
        "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0\\VC\\Lib\\x64",
        "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0\\Lib\\x64",
    ],
    "LIBPATH": [],
    "VSCMD_ARG_app_plat": [],
    "VCINSTALLDIR": [],
    "VCToolsInstallDir": []
}

# Specifying MSVC_VERSION is recommended
env = Environment(MSVC_VERSION='8.0', MSVC_USE_SETTINGS=msvc_use_settings)
</programlisting>
</para>

<para>
Important usage details:
<itemizedlist>

<listitem><para>
&cv-MSVC_USE_SETTINGS; must be passed as an argument to the &f-link-Environment;
constructor when an msvc tool (e.g., &t-link-msvc;, &t-link-msvs;, etc.) is
loaded via the default tools list or via a tools list passed to the
&f-link-Environment; constructor.
Otherwise, &cv-MSVC_USE_SETTINGS; must be set before the first msvc tool is
loaded into the environment.
</para></listitem>

<listitem><para>
<emphasis>
The dictionary content requirements are based on the internal msvc implementation and
therefore may change at any time.
</emphasis>
The burden is on the user to ensure the dictionary contents are minimally sufficient to
ensure successful builds.
</para>

</listitem>

</itemizedlist>
</para>

<para><emphasis>New in version 4.4</emphasis></para>

</summary>
</cvar>

<!-- This has moved to Platform/Platform.xml to avoid duplication
<cvar name="HOST_ARCH">
<summary>
<para>
</para>
</summary>
</cvar>
-->

<!-- This has moved to Platform/Platform.xml to avoid duplication
<cvar name="TARGET_ARCH">
<summary>
<para>
</para>
</summary>
</cvar>
-->

<cvar name="MSVC_UWP_APP">
<summary>
<para>
Build with the Universal Windows Platform (UWP) application &MSVC; libraries.
</para>

<para>
The valid values for &cv-MSVC_UWP_APP; are: <literal>True</literal>,
<literal>'1'</literal>, <literal>False</literal>, <literal>'0'</literal>,
or <literal>None</literal>.
</para>

<para>
When &cv-MSVC_UWP_APP; is enabled (i.e., <literal>True</literal> or
<literal>'1'</literal>), the &MSVC; environment will be set up to point
to the Windows Store compatible libraries and &MSVC; runtimes. In doing so,
any libraries that are built will be able to be used in a UWP App and published
to the Windows Store.
<!-- This flag will only have an effect with Visual Studio 2015 or later. -->
<!-- This variable must be passed as an argument to the Environment()
constructor; setting it later has no effect. -->
</para>

<para>
An exception is raised when any of the following conditions are satisfied:
<itemizedlist>
<listitem><para>
&cv-MSVC_UWP_APP; is enabled for Visual Studio 2013 and earlier.
</para></listitem>
<listitem><para>
&cv-MSVC_UWP_APP; is enabled and a UWP argument is specified in
&cv-link-MSVC_SCRIPT_ARGS;. Multiple UWP declarations via &cv-MSVC_UWP_APP;
and &cv-link-MSVC_SCRIPT_ARGS; are not allowed.
</para></listitem>
</itemizedlist>
</para>

<para>
Example - A Visual Studio 2022 build for the Universal Windows Platform:
<example_commands>
env = Environment(MSVC_VERSION='14.3', MSVC_UWP_APP=True)
</example_commands>
</para>

<para>
Important usage details:
<itemizedlist>

<listitem><para>
&cv-MSVC_UWP_APP; must be passed as an argument to the &f-link-Environment;
constructor when an msvc tool (e.g., &t-link-msvc;, &t-link-msvs;, etc.) is
loaded via the default tools list or via a tools list passed to the
&f-link-Environment; constructor.
Otherwise, &cv-MSVC_UWP_APP; must be set before the first msvc tool is
loaded into the environment.
</para></listitem>

<listitem><para>
<emphasis>
The existence of the UWP libraries is not verified when &cv-MSVC_UWP_APP; is enabled
which could result in build failures.
</emphasis>
The burden is on the user to ensure the requisite UWP libraries are installed.
</para></listitem>

</itemizedlist>
</para>

</summary>
</cvar>

<cvar name="VSWHERE">
<summary>
<para>
Specify the location of <command>vswhere.exe</command>.
</para>

<para>
    The <command>vswhere.exe</command> executable is distributed with
    Microsoft Visual Studio and Build Tools since the 2017 edition,
    but is also available as a standalone installation.
    It allows queries to obtain detailed information about
    installations of 2017 and later editions.
    &SCons; makes use of this information to determine
    the state of compiler support for those editions.
</para>
<para>
    Setting the &cv-VSWHERE; variable to the path to a specific
    <command>vswhere.exe</command> binary
    causes &SCons; to use that binary.
    If not set, &SCons; will search for one,
    looking in the following locations in order,
    using the first found
    (&cv-VSWHERE; is updated with the location):
</para>

<simplelist type="vert">
<member><literal>%ProgramFiles(x86)%\Microsoft Visual Studio\Installer</literal></member>
<member><literal>%ProgramFiles%\Microsoft Visual Studio\Installer</literal></member>
<member><literal>%ChocolateyInstall%\bin</literal></member>
<member><literal>%LOCALAPPDATA%\Microsoft\WinGet\Links</literal></member>
<member><literal>%USERPROFILE%\scoop\shims</literal></member>
<member><literal>%SCOOP%\shims</literal></member>
</simplelist>


<note>
  <para>
    In order to take effect, &cv-VSWHERE; must be set before
    the initial &MSVC; compiler discovery takes place.
    Discovery happens, at the latest, during the first call to the
    &f-link-Environment; function, unless a <parameter>tools</parameter>
    list is specified which excludes the entire &MSVC; toolchain -
    that is, omits <literal>"defaults"</literal>
    and any specific tool module that refers to parts of the toolchain
    (&t-link-msvc;, &t-link-mslink;, &t-link-masm;, &t-link-midl;
    and &t-link-msvs;). In this case, detection is deferred until
    any one of those tool modules is invoked manually.
    The following two examples illustrate this:
  </para>

  <programlisting>
# VSWHERE set as Environment is created
env = Environment(VSWHERE='c:/my/path/to/vswhere')

# Initialization deferred with empty tools, triggered manually
env = Environment(tools=[])
env['VSWHERE'] = r'c:/my/vswhere/install/location/vswhere.exe'
env.Tool('msvc')
env.Tool('mslink')
env.Tool('msvs')
  </programlisting>
</note>

</summary>
</cvar>

<cvar name="MSVC_NOTFOUND_POLICY">
<summary>
<para>
Specify the &scons; behavior when the &MSVC; compiler is not detected.
</para>

<para>
    The &cv-MSVC_NOTFOUND_POLICY; specifies the &scons; behavior when no msvc versions are detected or
    when the requested msvc version is not detected.
</para>

<para>
The valid values for &cv-MSVC_NOTFOUND_POLICY; and the corresponding &scons; behavior are:
</para>

<variablelist>

<varlistentry>
<term><parameter>'Error' or 'Exception'</parameter></term>
<listitem>
<para>
Raise an exception when no msvc versions are detected or when the requested msvc version is not detected.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term><parameter>'Warning' or 'Warn'</parameter></term>
<listitem>
<para>
Issue a warning and continue when no msvc versions are detected or when the requested msvc version is not detected.
Depending on usage, this could result in build failure(s).
</para>
</listitem>
</varlistentry>

<varlistentry>
<term><parameter>'Ignore' or 'Suppress'</parameter></term>
<listitem>
<para>
Take no action and continue when no msvc versions are detected or when the requested msvc version is not detected.
Depending on usage, this could result in build failure(s).
</para>
</listitem>
</varlistentry>

</variablelist>

<para>
Note: in addition to the camel case values shown above, lower case and upper case values are accepted as well.
</para>

<para>
The &cv-MSVC_NOTFOUND_POLICY; is applied when any of the following conditions are satisfied:
<itemizedlist>
<listitem><para>
&cv-MSVC_VERSION; is specified, the default tools list is implicitly defined (i.e., the tools list is not specified),
and the default tools list contains one or more of the msvc tools.
</para></listitem>
<listitem><para>
&cv-MSVC_VERSION; is specified, the default tools list is explicitly specified (e.g., <literal>tools=['default']</literal>),
and the default tools list contains one or more of the msvc tools.
</para></listitem>
<listitem><para>
A non-default tools list is specified that contains one or more of the msvc tools (e.g., <literal>tools=['msvc', 'mslink']</literal>).
</para></listitem>
</itemizedlist>
</para>

<para>
The &cv-MSVC_NOTFOUND_POLICY; is ignored when any of the following conditions are satisfied:
<itemizedlist>
<listitem><para>
&cv-MSVC_VERSION; is not specified and the default tools list is implicitly defined (i.e., the tools list is not specified).
</para></listitem>
<listitem><para>
&cv-MSVC_VERSION; is not specified and the default tools list is explicitly specified (e.g., <literal>tools=['default']</literal>).
</para></listitem>
<listitem><para>
A non-default tool list is specified that does not contain any of the msvc tools (e.g., <literal>tools=['mingw']</literal>).
</para></listitem>
</itemizedlist>
</para>

<para>
Important usage details:
<itemizedlist>

<listitem><para>
&cv-MSVC_NOTFOUND_POLICY; must be passed as an argument to the &f-link-Environment;
constructor when an msvc tool (e.g., &t-link-msvc;, &t-link-msvs;, etc.) is
loaded via the default tools list or via a tools list passed to the
&f-link-Environment; constructor.
Otherwise, &cv-MSVC_NOTFOUND_POLICY; must be set before the first msvc tool is
loaded into the environment.
</para></listitem>

</itemizedlist>
</para>

<para>
When &cv-MSVC_NOTFOUND_POLICY; is not specified, the default &scons; behavior is to issue a warning and continue
subject to the conditions listed above. The default &scons; behavior may change in the future.
</para>

<para><emphasis>New in version 4.4</emphasis></para>

</summary>
</cvar>

<cvar name="MSVC_SCRIPTERROR_POLICY">
<summary>
<para>
Specify the &scons; behavior when &MSVC; batch file errors are detected.
</para>

<para>
The &cv-MSVC_SCRIPTERROR_POLICY; specifies the &scons; behavior when msvc batch file errors are
detected.
When &cv-MSVC_SCRIPTERROR_POLICY; is not specified, the default &scons; behavior is to suppress
msvc batch file error messages.
</para>
<para>
The root cause of msvc build failures may be difficult to diagnose. In these situations, setting
the &scons; behavior to issue a warning when msvc batch file errors are detected <emphasis>may</emphasis>
produce additional diagnostic information.
</para>

<para>
The valid values for &cv-MSVC_SCRIPTERROR_POLICY; and the corresponding &scons; behavior are:
</para>

<variablelist>

<varlistentry>
<term><parameter>'Error' or 'Exception'</parameter></term>
<listitem>
<para>
Raise an exception when msvc batch file errors are detected.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term><parameter>'Warning' or 'Warn'</parameter></term>
<listitem>
<para>
Issue a warning when msvc batch file errors are detected.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term><parameter>'Ignore' or 'Suppress'</parameter></term>
<listitem>
<para>
Suppress msvc batch file error messages.
</para>

<para><emphasis>New in version 4.4</emphasis></para>

</listitem>
</varlistentry>

</variablelist>

<para>
Note: in addition to the camel case values shown above, lower case and upper case values are accepted as well.
</para>

<para>
Example 1 - A Visual Studio 2022 build with user-defined script arguments:
<example_commands>
env = environment(MSVC_VERSION='14.3', MSVC_SCRIPT_ARGS=['8.1', 'store', '-vcvars_ver=14.1'])
env.Program('hello', ['hello.c'], CCFLAGS='/MD', LIBS=['kernel32', 'user32', 'runtimeobject'])
</example_commands>
</para>

<para>
Example 1 - Output fragment:
<example_commands>
...
link /nologo /OUT:_build001\hello.exe kernel32.lib user32.lib runtimeobject.lib _build001\hello.obj
LINK : fatal error LNK1104: cannot open file 'MSVCRT.lib'
...
</example_commands>
</para>

<para>
Example 2 - A Visual Studio 2022 build with user-defined script arguments and the script error policy set
to issue a warning when msvc batch file errors are detected:
<example_commands>
env = environment(MSVC_VERSION='14.3', MSVC_SCRIPT_ARGS=['8.1', 'store', '-vcvars_ver=14.1'], MSVC_SCRIPTERROR_POLICY='warn')
env.Program('hello', ['hello.c'], CCFLAGS='/MD', LIBS=['kernel32', 'user32', 'runtimeobject'])
</example_commands>
</para>

<para>
Example 2 - Output fragment:
<example_commands>
...
scons: warning: vc script errors detected:
[ERROR:vcvars.bat] The UWP Application Platform requires a Windows 10 SDK.
[ERROR:vcvars.bat] WindowsSdkDir = "C:\Program Files (x86)\Windows Kits\8.1\"
[ERROR:vcvars.bat] host/target architecture is not supported : { x64 , x64 }
...
link /nologo /OUT:_build001\hello.exe kernel32.lib user32.lib runtimeobject.lib _build001\hello.obj
LINK : fatal error LNK1104: cannot open file 'MSVCRT.lib'
</example_commands>
</para>

<para>
Important usage details:
<itemizedlist>

<listitem><para>
&cv-MSVC_SCRIPTERROR_POLICY; must be passed as an argument to the &f-link-Environment;
constructor when an msvc tool (e.g., &t-link-msvc;, &t-link-msvs;, etc.) is
loaded via the default tools list or via a tools list passed to the
&f-link-Environment; constructor.
Otherwise, &cv-MSVC_SCRIPTERROR_POLICY; must be set before the first msvc tool is
loaded into the environment.
</para></listitem>

<listitem><para>
Due to &scons; implementation details, not all Windows system environment variables are propagated
to the environment in which the msvc batch file is executed.  Depending on Visual Studio version
and installation options, non-fatal msvc batch file error messages may be generated for ancillary
tools which may not affect builds with the msvc compiler.  For this reason, caution is recommended
when setting the script error policy to raise an exception (e.g., <literal>'Error'</literal>).
</para></listitem>

</itemizedlist>
</para>

<para><emphasis>New in version 4.4</emphasis></para>

</summary>
</cvar>

<cvar name="MSVC_SCRIPT_ARGS">
<summary>
<para>
Pass user-defined arguments to the &MSVC; batch file determined via autodetection.
</para>

<para>
&cv-MSVC_SCRIPT_ARGS; is available for msvc batch file arguments that do not have first-class support
via &consvars; or when there is an issue with the appropriate &consvar; validation.
When available, it is recommended to use the appropriate &consvars; (e.g., &cv-link-MSVC_TOOLSET_VERSION;)
rather than &cv-MSVC_SCRIPT_ARGS; arguments.
</para>

<para>
The valid values for &cv-MSVC_SCRIPT_ARGS; are: <literal>None</literal>, a string,
or a list of strings.
</para>

<para>
The &cv-MSVC_SCRIPT_ARGS; value is converted to a scalar string (i.e., "flattened").
The resulting scalar string, if not empty, is passed as an argument to the msvc batch file determined
via autodetection subject to the validation conditions listed below.
</para>

<para>
&cv-MSVC_SCRIPT_ARGS; is ignored when the value is <literal>None</literal> and when the
result from argument conversion is an empty string.  The validation conditions below do not apply.
</para>

<para>
An exception is raised when any of the following conditions are satisfied:
<itemizedlist>

<listitem><para>
&cv-MSVC_SCRIPT_ARGS; is specified for Visual Studio 2013 and earlier.
</para></listitem>

<listitem><para>
Multiple SDK version arguments (e.g., <literal>'10.0.20348.0'</literal>) are specified
in &cv-MSVC_SCRIPT_ARGS;.
</para></listitem>

<listitem><para>
&cv-link-MSVC_SDK_VERSION; is specified and an SDK version argument
(e.g., <literal>'10.0.20348.0'</literal>) is specified in &cv-MSVC_SCRIPT_ARGS;.
Multiple SDK version declarations via &cv-link-MSVC_SDK_VERSION; and &cv-MSVC_SCRIPT_ARGS;
are not allowed.
</para></listitem>

<listitem><para>
Multiple toolset version arguments (e.g., <literal>'-vcvars_ver=14.29'</literal>)
are specified in &cv-MSVC_SCRIPT_ARGS;.
</para></listitem>

<listitem><para>
&cv-link-MSVC_TOOLSET_VERSION; is specified and a toolset version argument
(e.g., <literal>'-vcvars_ver=14.29'</literal>) is specified in &cv-MSVC_SCRIPT_ARGS;.
Multiple toolset version declarations via &cv-link-MSVC_TOOLSET_VERSION; and
&cv-MSVC_SCRIPT_ARGS; are not allowed.
</para></listitem>

<listitem><para>
Multiple spectre library arguments (e.g., <literal>'-vcvars_spectre_libs=spectre'</literal>)
are specified in &cv-MSVC_SCRIPT_ARGS;.
</para></listitem>

<listitem><para>
&cv-link-MSVC_SPECTRE_LIBS; is enabled and a spectre library argument
(e.g., <literal>'-vcvars_spectre_libs=spectre'</literal>) is specified in
&cv-MSVC_SCRIPT_ARGS;. Multiple spectre library declarations via &cv-link-MSVC_SPECTRE_LIBS;
and &cv-MSVC_SCRIPT_ARGS; are not allowed.
</para></listitem>

<listitem><para>
Multiple UWP arguments (e.g., <literal>uwp</literal> or <literal>store</literal>) are specified
in &cv-MSVC_SCRIPT_ARGS;.
</para></listitem>

<listitem><para>
&cv-link-MSVC_UWP_APP; is enabled and a UWP argument (e.g., <literal>uwp</literal> or
<literal>store</literal>) is specified in &cv-MSVC_SCRIPT_ARGS;. Multiple UWP declarations
via &cv-link-MSVC_UWP_APP; and &cv-MSVC_SCRIPT_ARGS; are not allowed.
</para></listitem>

</itemizedlist>
</para>

<para>
Example 1 - A Visual Studio 2022 build with an SDK version and a toolset version
specified with a string argument:
<example_commands>
env = Environment(MSVC_VERSION='14.3', MSVC_SCRIPT_ARGS='10.0.20348.0 -vcvars_ver=14.29.30133')
</example_commands>
</para>

<para>
Example 2 - A Visual Studio 2022 build with an SDK version and a toolset version
specified with a list argument:
<example_commands>
env = Environment(MSVC_VERSION='14.3', MSVC_SCRIPT_ARGS=['10.0.20348.0', '-vcvars_ver=14.29.30133'])
</example_commands>
</para>

<para>
Important usage details:
<itemizedlist>

<listitem><para>
&cv-MSVC_SCRIPT_ARGS; must be passed as an argument to the &f-link-Environment;
constructor when an msvc tool (e.g., &t-link-msvc;, &t-link-msvs;, etc.) is
loaded via the default tools list or via a tools list passed to the
&f-link-Environment; constructor.
Otherwise, &cv-MSVC_SCRIPT_ARGS; must be set before the first msvc tool is
loaded into the environment.
</para></listitem>

<listitem><para>
Other than checking for multiple declarations as described above, &cv-MSVC_SCRIPT_ARGS; arguments
are not validated.
</para></listitem>

<listitem><para>
<emphasis>
Erroneous, inconsistent, and/or version incompatible &cv-MSVC_SCRIPT_ARGS; arguments are likely
to result in build failures for reasons that are not readily apparent and may be difficult to diagnose.
</emphasis>
The burden is on the user to ensure that the arguments provided to the msvc batch file are valid, consistent
and compatible with the version of msvc selected.
</para></listitem>

</itemizedlist>
</para>

<para><emphasis>New in version 4.4</emphasis></para>

</summary>
</cvar>

<cvar name="MSVC_SDK_VERSION">
<summary>
<para>
Build with a specific version of the Microsoft Software Development Kit (SDK).
</para>

<para>
The valid values for &cv-MSVC_SDK_VERSION; are: <literal>None</literal>
or a string containing the requested SDK version (e.g., <literal>'10.0.20348.0'</literal>).
</para>

<para>
&cv-MSVC_SDK_VERSION; is ignored when the value is <literal>None</literal> and when
the value is an empty string.  The validation conditions below do not apply.
</para>

<para>
An exception is raised when any of the following conditions are satisfied:
<itemizedlist>

<listitem><para>
&cv-MSVC_SDK_VERSION; is specified for Visual Studio 2013 and earlier.
</para></listitem>

<listitem><para>
&cv-MSVC_SDK_VERSION; is specified and an SDK version argument is specified in
&cv-link-MSVC_SCRIPT_ARGS;. Multiple SDK version declarations via &cv-MSVC_SDK_VERSION;
and &cv-link-MSVC_SCRIPT_ARGS; are not allowed.
</para></listitem>

<listitem><para>
The &cv-MSVC_SDK_VERSION; specified does not match any of the supported formats:
<itemizedlist>
<listitem><para>
<literal>'10.0.XXXXX.Y'</literal> [SDK 10.0]
</para></listitem>
<listitem><para>
<literal>'8.1'</literal> [SDK 8.1]
</para></listitem>
</itemizedlist>
</para></listitem>

<listitem><para>
The system folder for the corresponding &cv-MSVC_SDK_VERSION; version is not found.
The requested SDK version does not appear to be installed.
</para></listitem>

<listitem><para>
The &cv-MSVC_SDK_VERSION; version does not appear to support the requested platform
type (i.e., <literal>UWP</literal> or <literal>Desktop</literal>).  The requested SDK version
platform type components do not appear to be installed.
</para></listitem>

<listitem><para>
The &cv-MSVC_SDK_VERSION; version is <literal>8.1</literal>, the platform type is
<literal>UWP</literal>, and the build tools selected are from Visual Studio 2017
and later (i.e., &cv-link-MSVC_VERSION; must be '14.0' or &cv-link-MSVC_TOOLSET_VERSION;
must be '14.0').
</para></listitem>

</itemizedlist>
</para>

<para>
Example 1 - A Visual Studio 2022 build with a specific Windows SDK version:
<example_commands>
env = Environment(MSVC_VERSION='14.3', MSVC_SDK_VERSION='10.0.20348.0')
</example_commands>
</para>

<para>
Example 2 - A Visual Studio 2022 build with a specific SDK version for the Universal Windows Platform:
<example_commands>
env = Environment(MSVC_VERSION='14.3', MSVC_SDK_VERSION='10.0.20348.0', MSVC_UWP_APP=True)
</example_commands>
</para>

<para>
Important usage details:
<itemizedlist>

<listitem><para>
&cv-MSVC_SDK_VERSION; must be passed as an argument to the &f-link-Environment;
constructor when an msvc tool (e.g., &t-link-msvc;, &t-link-msvs;, etc.) is
loaded via the default tools list or via a tools list passed to the
&f-link-Environment; constructor.
Otherwise, &cv-MSVC_SDK_VERSION; must be set before the first msvc tool is
loaded into the environment.
</para></listitem>

<listitem>
<para><emphasis>
Should a SDK 10.0 version be installed that does not follow the naming scheme above, the
SDK version will need to be specified via &cv-link-MSVC_SCRIPT_ARGS; until the version number
validation format can be extended.
</emphasis></para>
</listitem>

<listitem><para>
Should an exception be raised indicating that the SDK version is not found, verify that
the requested SDK version is installed with the necessary platform type components.
</para></listitem>

<listitem><para>
There is a known issue with the Microsoft libraries when the target architecture is
<literal>ARM64</literal> and a Windows 11 SDK (version <literal>'10.0.22000.0'</literal> and later) is used
with the <literal>v141</literal> build tools and older <literal>v142</literal> toolsets
(versions <literal>'14.28.29333'</literal> and earlier). Should build failures arise with these combinations
of settings due to unresolved symbols in the Microsoft libraries, &cv-MSVC_SDK_VERSION; may be employed to
specify a Windows 10 SDK (e.g., <literal>'10.0.20348.0'</literal>) for the build.
</para></listitem>

</itemizedlist>
</para>

<para><emphasis>New in version 4.4</emphasis></para>

</summary>
</cvar>

<cvar name="MSVC_TOOLSET_VERSION">
<summary>
<para>
Build with a specific &MSVC; toolset version.
</para>

<para><emphasis>
Specifying &cv-MSVC_TOOLSET_VERSION; does not affect the autodetection and selection
of msvc instances. The &cv-MSVC_TOOLSET_VERSION; is applied <emphasis>after</emphasis>
an msvc instance is selected. This could be the default version of msvc if &cv-link-MSVC_VERSION;
is not specified.
</emphasis></para>

<para>
The valid values for &cv-MSVC_TOOLSET_VERSION; are: <literal>None</literal>
or a string containing the requested toolset version (e.g., <literal>'14.29'</literal>).
</para>

<para>
&cv-MSVC_TOOLSET_VERSION; is ignored when the value is <literal>None</literal> and when
the value is an empty string.  The validation conditions below do not apply.
</para>

<para>
An exception is raised when any of the following conditions are satisfied:
<itemizedlist>

<listitem><para>
&cv-MSVC_TOOLSET_VERSION; is specified for Visual Studio 2015 and earlier.
</para></listitem>

<listitem><para>
&cv-MSVC_TOOLSET_VERSION; is specified and a toolset version argument is specified in
&cv-link-MSVC_SCRIPT_ARGS;. Multiple toolset version declarations via &cv-MSVC_TOOLSET_VERSION;
and &cv-link-MSVC_SCRIPT_ARGS; are not allowed.
</para></listitem>

<listitem>
<para>
The &cv-MSVC_TOOLSET_VERSION; specified does not match any of the supported formats:
</para>

<itemizedlist>

<listitem><para>
<literal>'XX.Y'</literal>
</para></listitem>

<listitem><para>
<literal>'XX.YY'</literal>
</para></listitem>

<listitem><para>
<literal>'XX.YY.ZZZZZ'</literal>
</para></listitem>

<listitem><para>
<literal>'XX.YY.Z'</literal> to <literal>'XX.YY.ZZZZ'</literal>
<emphasis>
[&scons; extension not directly supported by the msvc batch files and may be removed in the future]
</emphasis>
</para></listitem>

<listitem><para>
<literal>'XX.YY.ZZ.N'</literal> [SxS format]
</para></listitem>

<listitem><para>
<literal>'XX.YY.ZZ.NN'</literal> [SxS format]
</para></listitem>

</itemizedlist>

</listitem>

<listitem><para>
The major msvc version prefix (i.e., <literal>'XX.Y'</literal>) of the &cv-MSVC_TOOLSET_VERSION; specified
is for Visual Studio 2013 and earlier (e.g., <literal>'12.0'</literal>).
</para></listitem>

<listitem><para>
The major msvc version prefix (i.e., <literal>'XX.Y'</literal>) of the &cv-MSVC_TOOLSET_VERSION; specified
is greater than the msvc version selected (e.g., <literal>'99.0'</literal>).
</para></listitem>

<listitem><para>
A system folder for the corresponding &cv-MSVC_TOOLSET_VERSION; version is not found.
The requested toolset version does not appear to be installed.
</para></listitem>

</itemizedlist>
</para>

<para>
Toolset selection details:
<itemizedlist>

<listitem><para>
When &cv-MSVC_TOOLSET_VERSION; is not an SxS version number or a full toolset version number:
the first toolset version, ranked in descending order, that matches the &cv-MSVC_TOOLSET_VERSION;
prefix is selected.
</para></listitem>

<listitem><para>
When &cv-MSVC_TOOLSET_VERSION; is specified using the major msvc version prefix
(i.e., <literal>'XX.Y'</literal>) and the major msvc version is that of the latest release of
Visual Studio, the selected toolset version may not be the same as the default &MSVC; toolset version.
</para><para>
In the latest release of Visual Studio, the default &MSVC; toolset version is not necessarily the
toolset with the largest version number.
</para></listitem>

</itemizedlist>
</para>

<para>
Example 1 - A default Visual Studio build with a partial toolset version specified:
<example_commands>
env = Environment(MSVC_TOOLSET_VERSION='14.2')
</example_commands>
</para>

<para>
Example 2 - A default Visual Studio build with a partial toolset version specified:
<example_commands>
env = Environment(MSVC_TOOLSET_VERSION='14.29')
</example_commands>
</para>

<para>
Example 3 - A Visual Studio 2022 build with a full toolset version specified:
<example_commands>
env = Environment(MSVC_VERSION='14.3', MSVC_TOOLSET_VERSION='14.29.30133')
</example_commands>
</para>

<para>
Example 4 - A Visual Studio 2022 build with an SxS toolset version specified:
<example_commands>
env = Environment(MSVC_VERSION='14.3', MSVC_TOOLSET_VERSION='14.29.16.11')
</example_commands>
</para>

<para>
Important usage details:
<itemizedlist>

<listitem><para>
&cv-MSVC_TOOLSET_VERSION; must be passed as an argument to the &f-link-Environment;
constructor when an msvc tool (e.g., &t-link-msvc;, &t-link-msvs;, etc.) is
loaded via the default tools list or via a tools list passed to the
&f-link-Environment; constructor.
Otherwise, &cv-MSVC_TOOLSET_VERSION; must be set before the first msvc tool is
loaded into the environment.
</para></listitem>

<listitem><para>
<emphasis>
The existence of the toolset host architecture and target architecture folders are not verified
when &cv-MSVC_TOOLSET_VERSION; is specified which could result in build failures.
</emphasis>
The burden is on the user to ensure the requisite toolset target architecture build tools are installed.
</para></listitem>

</itemizedlist>
</para>

<para><emphasis>New in version 4.4</emphasis></para>

</summary>
</cvar>

<cvar name="MSVC_SPECTRE_LIBS">
<summary>
<para>
Build with the spectre-mitigated &MSVC; libraries.
</para>

<para>
The valid values for &cv-MSVC_SPECTRE_LIBS; are: <literal>True</literal>,
<literal>False</literal>, or <literal>None</literal>.
</para>

<para>
When &cv-MSVC_SPECTRE_LIBS; is enabled (i.e., <literal>True</literal>),
the &MSVC; environment will include the paths to the spectre-mitigated implementations
of the &MSVC; libraries.
</para>

<para>
An exception is raised when any of the following conditions are satisfied:
<itemizedlist>

<listitem><para>
&cv-MSVC_SPECTRE_LIBS; is enabled for Visual Studio 2015 and earlier.
</para></listitem>

<listitem><para>
&cv-MSVC_SPECTRE_LIBS; is enabled and a spectre library argument is specified in
&cv-link-MSVC_SCRIPT_ARGS;. Multiple spectre library declarations via &cv-MSVC_SPECTRE_LIBS;
and &cv-link-MSVC_SCRIPT_ARGS; are not allowed.
</para></listitem>

<listitem><para>
&cv-MSVC_SPECTRE_LIBS; is enabled and the platform type is <literal>UWP</literal>. There
are no spectre-mitigated libraries for Universal Windows Platform (UWP) applications or
components.
</para></listitem>

</itemizedlist>
</para>

<para>
Example - A Visual Studio 2022 build with spectre mitigated &MSVC; libraries:
<example_commands>
env = Environment(MSVC_VERSION='14.3', MSVC_SPECTRE_LIBS=True)
</example_commands>
</para>

<para>
Important usage details:
<itemizedlist>

<listitem><para>
&cv-MSVC_SPECTRE_LIBS; must be passed as an argument to the &f-link-Environment;
constructor when an msvc tool (e.g., &t-link-msvc;, &t-link-msvs;, etc.) is
loaded via the default tools list or via a tools list passed to the
&f-link-Environment; constructor.
Otherwise, &cv-MSVC_SPECTRE_LIBS; must be set before the first msvc tool is
loaded into the environment.
</para></listitem>

<listitem><para>
Additional compiler switches (e.g., <literal>/Qspectre</literal>) are necessary for including
spectre mitigations when building user artifacts. Refer to the Visual Studio documentation for
details.
</para></listitem>

<listitem><para>
<emphasis>
The existence of the spectre libraries host architecture and target architecture folders are not
verified when &cv-MSVC_SPECTRE_LIBS; is enabled which could result in build failures.
</emphasis>
The burden is on the user to ensure the requisite libraries with spectre mitigations are installed.
</para></listitem>

</itemizedlist>
</para>

<para><emphasis>New in version 4.4</emphasis></para>

</summary>
</cvar>

</sconsdoc>