3 README - SCons.Tool.MSCommon
4 ############################
6 .. contents:: **Table of Contents**
14 * Public, user-callable functions and exception types are available via
15 the ``SCons.Tool.MSCommon`` namespace.
17 * Some existing code has been moved from ``MSCommon/vc.py`` to the appropriate
18 ``MSCommon/MSVC/<modulename>``.
20 * No functions from the MSVC module or its child modules are intended to be invoked directly.
21 All functions of interest are made available via the ``SCons.Tool.MSCommon`` namespace.
22 It is anticipated that more code may be moved in the future as new features are added.
23 By exposing the public API through ``SCons.Tool.MSCommon`` there should not be a problem
26 * Additional helper functions primarily used for the test suite were added to
27 ``MSCommon/vc.py`` and are available via the ``SCons.Tool.MSCommon`` namespace.
30 MSVC Detection Priority
31 =======================
33 For msvc version specifications without an 'Exp' suffix, an express
34 installation is used only when no other installation is detected.
36 +---------+---------+----------------------------------------------------------+
37 | Product | VCVer | Priority |
38 +=========+=========+==========================================================+
39 | VS2022 | 14.3 | Enterprise, Professional, Community, BuildTools |
40 +---------+---------+----------------------------------------------------------+
41 | VS2019 | 14.2 | Enterprise, Professional, Community, BuildTools |
42 +---------+---------+----------------------------------------------------------+
43 | VS2017 | 14.1 | Enterprise, Professional, Community, BuildTools, Express |
44 +---------+---------+----------------------------------------------------------+
45 | VS2017 | 14.1Exp | Express |
46 +---------+---------+----------------------------------------------------------+
47 | VS2015 | 14.0 | [Develop, BuildTools, CmdLine], Express |
48 +---------+---------+----------------------------------------------------------+
49 | VS2015 | 14.0Exp | Express |
50 +---------+---------+----------------------------------------------------------+
51 | VS2013 | 12.0 | Develop, Express |
52 +---------+---------+----------------------------------------------------------+
53 | VS2013 | 12.0Exp | Express |
54 +---------+---------+----------------------------------------------------------+
55 | VS2012 | 11.0 | Develop, Express |
56 +---------+---------+----------------------------------------------------------+
57 | VS2012 | 11.0Exp | Express |
58 +---------+---------+----------------------------------------------------------+
59 | VS2010 | 10.0 | Develop, Express |
60 +---------+---------+----------------------------------------------------------+
61 | VS2010 | 10.0Exp | Express |
62 +---------+---------+----------------------------------------------------------+
63 | VS2008 | 9.0 | Develop, VCForPython, Express |
64 +---------+---------+----------------------------------------------------------+
65 | VS2008 | 9.0Exp | Express |
66 +---------+---------+----------------------------------------------------------+
67 | VS2005 | 8.0 | Develop, Express |
68 +---------+---------+----------------------------------------------------------+
69 | VS2005 | 8.0Exp | Express |
70 +---------+---------+----------------------------------------------------------+
71 | VS2003 | 7.1 | Develop |
72 +---------+---------+----------------------------------------------------------+
73 | VS2002 | 7.0 | Develop |
74 +---------+---------+----------------------------------------------------------+
75 | VS6.0 | 6.0 | Develop |
76 +---------+---------+----------------------------------------------------------+
81 devenv.com or msdev.com is detected.
84 WDExpress.exe or VCExpress.exe is detected.
87 The vcvarsall batch file dispatches to the buildtools batch file.
90 Neither Develop, Express, or BuildTools.
92 VS2015 Edition Limitations
93 ==========================
98 The VS2015 BuildTools stand-alone batch file does not support the ``sdk version`` argument.
100 The VS2015 BuildTools stand-alone batch file does not support the ``store`` argument.
102 These arguments appear to be silently ignored and likely would result in compiler
103 and/or linker build failures.
105 The VS2015 BuildTools ``vcvarsall.bat`` batch file dispatches to the stand-alone buildtools
106 batch file under certain circumstances. A fragment from the vcvarsall batch file is:
110 if exist "%~dp0..\common7\IDE\devenv.exe" goto setup_VS
111 if exist "%~dp0..\common7\IDE\wdexpress.exe" goto setup_VS
112 if exist "%~dp0..\..\Microsoft Visual C++ Build Tools\vcbuildtools.bat" goto setup_buildsku
119 if not exist "%~dp0..\..\Microsoft Visual C++ Build Tools\vcbuildtools.bat" goto usage
121 call "%~dp0..\..\Microsoft Visual C++ Build Tools\vcbuildtools.bat" %1 %2
128 The VS2015 Express batch file does not support the ``sdk version`` argument.
130 The VS2015 Express batch file does not support the ``store`` argument for the ``amd64`` and
131 ``arm`` target architectures
133 amd64 Target Architecture
134 ^^^^^^^^^^^^^^^^^^^^^^^^^
136 As installed, VS2015 Express does not support the ``store`` argument for the ``amd64`` target
137 architecture. The generated ``store`` library paths include directories that do not exist.
139 The store library paths appear in two places in the ``vcvarsx86_amd64`` batch file:
144 @if exist "%VCINSTALLDIR%LIB\amd64\store" set LIB=%VCINSTALLDIR%LIB\amd64\store;%LIB%
147 @if exist "%VCINSTALLDIR%LIB\amd64\store" set LIBPATH=%VCINSTALLDIR%LIB\amd64\store;%LIBPATH%
149 The correct store library paths would be:
154 @if exist "%VCINSTALLDIR%LIB\store\amd64" set LIB=%VCINSTALLDIR%LIB\store\amd64;%LIB%
157 @if exist "%VCINSTALLDIR%LIB\store\amd64" set LIBPATH=%VCINSTALLDIR%LIB\store\amd64;%LIBPATH%
159 arm Target Architecture
160 ^^^^^^^^^^^^^^^^^^^^^^^
162 As installed, VS2015 Express does not support the ``store`` argument for the ``arm`` target
163 architecture. The generated ``store`` library paths include directories that do not exist.
165 The store library paths appear in two places in the ``vcvarsx86_arm`` batch file:
170 @if exist "%VCINSTALLDIR%LIB\ARM\store" set LIB=%VCINSTALLDIR%LIB\ARM\store;%LIB%
173 @if exist "%VCINSTALLDIR%LIB\ARM\store" set LIBPATH=%VCINSTALLDIR%LIB\ARM\store;%LIBPATH%
175 The correct store library paths would be file:
180 @if exist "%VCINSTALLDIR%LIB\store\ARM" set LIB=%VCINSTALLDIR%LIB\store\ARM;%LIB%
183 @if exist "%VCINSTALLDIR%LIB\store\ARM" set LIBPATH=%VCINSTALLDIR%LIB\store\ARM;%LIBPATH%
189 The following issues are known to exist:
191 * Using ``MSVC_USE_SCRIPT`` and ``MSVC_USE_SCRIPT_ARGS`` to call older Microsoft SDK
192 ``SetEnv.cmd`` batch files may result in build failures.
194 Typically, the reasons for build failures with SDK batch files are one, or both, of:
196 * The batch files require delayed expansion to be enabled which is not usually the Windows default.
198 * The batch files inspect environment variables that are not defined in the minimal subprocess
199 environment in which the batch files are invoked.
201 * The code to suppress the "No versions of the MSVC compiler were found" warning for
202 the default environment was moved from ``MSCommon/vc.py`` to ``MSCommon/MSVC/SetupEnvDefault.py``.
203 There are very few, if any, existing unit tests. Now that the code is isolated in its own
204 module with a limited API, unit tests may be easier to implement.
207 Experimental Features
208 =====================
210 msvc_query_version_toolset(version=None, prefer_newest=True, vswhere_exe=None)
211 ------------------------------------------------------------------------------
213 The experimental function ``msvc_query_version_toolset`` was added to ``MSCommon/vc.py``
214 and is available via the ``SCons.Tool.MSCommon`` namespace.
216 This function takes a version specification or a toolset version specification, an optional product
217 preference, and an optional vswhere executable location as arguments and returns the msvc version and
218 the msvc toolset version for the corresponding version specification.
220 This is a proxy for using the toolset version for selection until that functionality can be added.
237 '14.28.29333', # only 14.2
238 '14.20.29333', # fictitious for testing
241 for prefer_newest in (True, False):
243 msvc_version, msvc_toolset_version = msvc_query_version_toolset(version, prefer_newest=prefer_newest)
245 except MSVCToolsetVersionNotFound:
251 env = Environment(MSVC_VERSION=msvc_version, MSVC_TOOLSET_VERSION=msvc_toolset_version)
254 print('{}Query: {} version={}, prefer_newest={}'.format(newline, msg, version, prefer_newest))
256 Example output fragment
260 Build: _build003 {'MSVC_VERSION': '14.3', 'MSVC_TOOLSET_VERSION': '14.29.30133'}
261 Where: C:\Software\MSVS-2022-143-Com\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe
262 Where: C:\Software\MSVS-2022-143-Com\Common7\Tools\guidgen.exe
263 Query: passed version=14.2, prefer_newest=True
265 Build: _build004 {'MSVC_VERSION': '14.2', 'MSVC_TOOLSET_VERSION': '14.29.30133'}
266 Where: C:\Software\MSVS-2019-142-Com\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe
267 Where: C:\Software\MSVS-2019-142-Com\Common7\Tools\guidgen.exe
268 Query: passed version=14.2, prefer_newest=False
271 Undocumented Features
272 =====================
274 set SCONS_CACHE_MSVC_FORCE_DEFAULTS=1
275 -------------------------------------
277 The Windows system environment variable ``SCONS_CACHE_MSVC_FORCE_DEFAULTS`` was added. This variable is only
278 evaluated when the msvc cache is enabled and accepts the values ``1``, ``true``, and ``True``.
280 When enabled, the default msvc toolset version and the default sdk version, if not otherwise specified, are
281 added to the batch file argument list. This is intended to make the cache more resilient to Visual Studio
282 updates that may change the default toolset version and/or the default SDK version.
288 @echo Enabling scons cache ...
289 @set "SCONS_CACHE_MSVC_CONFIG=mycachefile.json"
290 @set "SCONS_CACHE_MSVC_FORCE_DEFAULTS=True"
293 End-User Diagnostic Tools
294 =========================
296 Due to the proliferation of user-defined msvc batch file arguments, the likelihood of end-user build
297 failures has increased.
299 Some of the options that may be employed in diagnosing end-user msvc build failures are listed below.
301 msvc_set_scripterror_policy('Warning') and MSVC_SCRIPTERROR_POLICY='Warning'
302 ----------------------------------------------------------------------------
304 Enabling warnings to be produced for detected msvc batch file errors may provide additional context
305 for build failures. Refer to the documentation for details.
307 Change the default policy:
311 from SCons.Tool.MSCommon import msvc_set_scripterror_policy
313 msvc_set_scripterror_policy('Warning')
315 Specify the policy per-environment:
319 env = Environment(MSVC_VERSION='14.3', MSVC_SPECTRE_LIBS=True, MSVC_SCRIPTERROR_POLICY='Warning')
322 set SCONS_MSCOMMON_DEBUG=mydebugfile.txt
323 ----------------------------------------
325 The traditional method of diagnosing end-user issues is to enable the internal msvc debug logging.
328 set SCONS_CACHE_MSVC_CONFIG=mycachefile.json
329 --------------------------------------------
331 On occasion, enabling the cache file can prove to be a useful diagnostic tool. If nothing else,
332 issues with the msvc environment may be readily apparent.
338 On occasion, the raw vswhere output may prove useful especially if there are suspected issues with
339 detection of installed msvc instances.
341 Windows command-line sample invocations:
346 "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -all -sort -prerelease -products * -legacy -format json >MYVSWHEREOUTPUT.json
349 "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -all -sort -prerelease -products * -legacy -format json >MYVSWHEREOUTPUT.json
352 Visual Studio Implementation Notes
353 ==================================
358 Supported MSVC batch file arguments by product:
360 +---------+---------+--------+---------+---------+
361 | Product | UWP | SDK | Toolset | Spectre |
362 +=========+=========+========+=========+=========+
363 | VS2022 | X | X | X | X |
364 +---------+---------+--------+---------+---------+
365 | VS2019 | X | X | X | X |
366 +---------+---------+--------+---------+---------+
367 | VS2017 | X | X | X | X |
368 +---------+---------+--------+---------+---------+
369 | VS2015 | X [1] | X [2] | | |
370 +---------+---------+--------+---------+---------+
374 1) The BuildTools edition does not support the ``store`` argument. The Express edition
375 supports the ``store`` argument for the ``x86`` target only.
376 2) The ``sdk version`` argument is not supported in the BuildTools and Express editions.
378 Supported MSVC batch file arguments in SCons:
380 +----------+----------------------------------------+-----------------------------------------------------+
381 | Argument | Construction Variable | Script Argument Equivalent |
382 +==========+========================================+=====================================================+
383 | UWP | ``MSVC_UWP_APP=True`` | ``MSVC_SCRIPT_ARGS='store'`` |
384 +----------+----------------------------------------+-----------------------------------------------------+
385 | SDK | ``MSVC_SDK_VERSION='10.0.20348.0'`` | ``MSVC_SCRIPT_ARGS='10.0.20348.0'`` |
386 +----------+----------------------------------------+-----------------------------------------------------+
387 | Toolset | ``MSVC_TOOLSET_VERSION='14.31.31103'`` | ``MSVC_SCRIPT_ARGS='-vcvars_ver=14.31.31103'`` |
388 +----------+----------------------------------------+-----------------------------------------------------+
389 | Spectre | ``MSVC_SPECTRE_LIBS=True`` | ``MSVC_SCRIPT_ARGS='-vcvars_spectre_libs=spectre'`` |
390 +----------+----------------------------------------+-----------------------------------------------------+
392 **MSVC_SCRIPT_ARGS contents are not validated. Utilizing script arguments that have construction
393 variable equivalents is discouraged and may lead to difficult to diagnose build errors.**
395 Additional constraints:
397 * ``MSVC_SDK_VERSION='8.1'`` and ``MSVC_UWP_APP=True`` is supported only for the v140
398 build tools (i.e., ``MSVC_VERSION='14.0'`` or ``MSVC_TOOLSET_VERSION='14.0'``).
400 * ``MSVC_SPECTRE_LIBS=True`` and ``MSVC_UWP_APP=True`` is not supported (i.e., there
401 are no spectre mitigations libraries for UWP builds).
403 Default Toolset Version
404 -----------------------
406 Side-by-side toolset versions were introduced in Visual Studio 2017.
407 The examples shown below are for Visual Studio 2022.
409 The msvc default toolset version is dependent on the installation options
410 selected. This means that the default toolset version may be different for
411 each machine given the same Visual Studio product.
413 The msvc default toolset is not necessarily the latest toolset installed.
414 This has implications when a toolset version is specified using only one minor
415 digit (e.g., ``MSVC_TOOLSET_VERSION='14.3'`` or ``MSVC_SCRIPT_ARGS='-vcvars_ver=14.3'``).
417 Explicitly defining ``MSVC_TOOLSET_VERSION=None`` will return the same toolset
418 that the msvc batch files would return. When using ``MSVC_SCRIPT_ARGS``, the
419 toolset specification should be omitted entirely.
421 Local installation and summary test results:
425 VS2022\VC\Auxiliary\Build\Microsoft.VCToolsVersion.v143.default.txt
428 VS2022\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt
431 Toolset version summary:
435 14.31.31103 Environment()
436 14.31.31103 Environment(MSVC_TOOLSET_VERSION=None)
438 14.32.31326* Environment(MSVC_TOOLSET_VERSION='14.3')
439 14.32.31326* Environment(MSVC_SCRIPT_ARGS=['-vcvars_ver=14.3'])
441 14.31.31103 Environment(MSVC_TOOLSET_VERSION='14.31')
442 14.31.31103 Environment(MSVC_SCRIPT_ARGS=['-vcvars_ver=14.31'])
444 14.32.31326 Environment(MSVC_TOOLSET_VERSION='14.32')
445 14.32.31326 Environment(MSVC_SCRIPT_ARGS=['-vcvars_ver=14.32'])
447 VS2022\\Common7\\Tools\\vsdevcmd\\ext\\vcvars.bat usage fragment:
451 @echo -vcvars_ver=version : Version of VC++ Toolset to select
452 @echo ** [Default] : If -vcvars_ver=version is NOT specified, the toolset specified by
453 @echo [VSInstallDir]\VC\Auxiliary\Build\Microsoft.VCToolsVersion.v143.default.txt will be used.
454 @echo ** 14.0 : VS 2015 (v140) VC++ Toolset (installation of the v140 toolset is a prerequisite)
455 @echo ** 14.xx : VS 2017 or VS 2019 VC++ Toolset, if that version is installed on the system under
456 @echo [VSInstallDir]\VC\MSVC\Tools\[version]. Where '14.xx' specifies a partial
457 @echo [version]. The latest [version] directory that matches the specified value will
459 @echo ** 14.xx.yyyyy : VS 2017 or VS 2019 VC++ Toolset, if that version is installed on the system under
460 @echo [VSInstallDir]\VC\MSVC\Tools\[version]. Where '14.xx.yyyyy' specifies an
461 @echo exact [version] directory to be used.
462 @echo ** 14.xx.VV.vv : VS 2019 C++ side-by-side toolset package identity alias, if the SxS toolset has been installed on the system.
463 @echo Where '14.xx.VV.vv' corresponds to a SxS toolset
464 @echo VV = VS Update Major Version (e.g. "16" for VS 2019 v16.9)
465 @echo vv = VS Update Minor version (e.g. "9" for VS 2019 v16.9)
466 @echo Please see [VSInstallDir]\VC\Auxiliary\Build\[version]\Microsoft.VCToolsVersion.[version].txt for mapping of
467 @echo SxS toolset to [VSInstallDir]\VC\MSVC\Tools\ directory.
469 VS2022 batch file fragment to determine the default toolset version:
474 set "__VCVARS_DEFAULT_CONFIG_FILE=%VCINSTALLDIR%Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"
476 @REM We will "fallback" to Microsoft.VCToolsVersion.default.txt (latest) if Microsoft.VCToolsVersion.v143.default.txt does not exist.
477 if EXIST "%VCINSTALLDIR%Auxiliary\Build\Microsoft.VCToolsVersion.v143.default.txt" (
478 if "%VSCMD_DEBUG%" GEQ "2" @echo [DEBUG:ext\%~nx0] Microsoft.VCToolsVersion.v143.default.txt was found.
479 set "__VCVARS_DEFAULT_CONFIG_FILE=%VCINSTALLDIR%Auxiliary\Build\Microsoft.VCToolsVersion.v143.default.txt"
482 if "%VSCMD_DEBUG%" GEQ "1" @echo [DEBUG:ext\%~nx0] Microsoft.VCToolsVersion.v143.default.txt was not found. Defaulting to 'Microsoft.VCToolsVersion.default.txt'.
485 Empirical evidence suggests that the default toolset version is different from the latest
486 toolset version when the toolset version immediately preceding the latest version is
487 installed. For example, the ``14.31`` toolset version is installed when the ``14.32``
488 toolset version is the latest.
491 Visual Studio Version Notes
492 ============================
497 +------+-------------------+
499 +======+===================+
500 | 10.0 | 10.0.XXXXX.Y [1] |
501 +------+-------------------+
503 +------+-------------------+
507 1) The Windows 10 SDK version number is 10.0.20348.0 and earlier.
509 The Windows 11 SDK version number is 10.0.22000.194 and later.
514 +-------------+-------+-------+
515 | BuildSeries | VCVER | CLVER |
516 +=============+=======+=======+
517 | 14.4 | 14.4X | 19.4 |
518 +-------------+-------+-------+
519 | 14.3 | 14.3X | 19.3 |
520 +-------------+-------+-------+
521 | 14.2 | 14.2X | 19.2 |
522 +-------------+-------+-------+
523 | 14.1 | 14.1X | 19.1 |
524 +-------------+-------+-------+
525 | 14.0 | 14.0 | 19.0 |
526 +-------------+-------+-------+
527 | 12.0 | 12.0 | 18.0 |
528 +-------------+-------+-------+
529 | 11.0 | 11.0 | 17.0 |
530 +-------------+-------+-------+
531 | 10.0 | 10.0 | 16.0 |
532 +-------------+-------+-------+
534 +-------------+-------+-------+
536 +-------------+-------+-------+
538 +-------------+-------+-------+
540 +-------------+-------+-------+
542 +-------------+-------+-------+
547 +------------+-------------+----------+
548 | BuildTools | BuildSeries | MSVCRT |
549 +============+=============+==========+
550 | v143 | 14.4, 14.3 | 140/ucrt |
551 +------------+-------------+----------+
552 | v142 | 14.2 | 140/ucrt |
553 +------------+-------------+----------+
554 | v141 | 14.1 | 140/ucrt |
555 +------------+-------------+----------+
556 | v140 | 14.0 | 140/ucrt |
557 +------------+-------------+----------+
558 | v120 | 12.0 | 120 |
559 +------------+-------------+----------+
560 | v110 | 11.0 | 110 |
561 +------------+-------------+----------+
562 | v100 | 10.0 | 100 |
563 +------------+-------------+----------+
565 +------------+-------------+----------+
567 +------------+-------------+----------+
569 +------------+-------------+----------+
571 +------------+-------------+----------+
573 +------------+-------------+----------+
578 +----------+-------+-------+-----------+------------------------+
579 | Product | VSVER | SCons | SDK | BuildTools |
580 +==========+=======+=======+===========+========================+
581 | 2022 | 17.0 | 14.3 | 10.0, 8.1 | v143, v142, v141, v140 |
582 +----------+-------+-------+-----------+------------------------+
583 | 2019 | 16.0 | 14.2 | 10.0, 8.1 | v142, v141, v140 |
584 +----------+-------+-------+-----------+------------------------+
585 | 2017 | 15.0 | 14.1 | 10.0, 8.1 | v141, v140 |
586 +----------+-------+-------+-----------+------------------------+
587 | 2015 | 14.0 | 14.0 | 10.0, 8.1 | v140 |
588 +----------+-------+-------+-----------+------------------------+
589 | 2013 | 12.0 | 12.0 | | v120 |
590 +----------+-------+-------+-----------+------------------------+
591 | 2012 | 11.0 | 11.0 | | v110 |
592 +----------+-------+-------+-----------+------------------------+
593 | 2010 | 10.0 | 10.0 | | v100 |
594 +----------+-------+-------+-----------+------------------------+
595 | 2008 | 9.0 | 9.0 | | v90 |
596 +----------+-------+-------+-----------+------------------------+
597 | 2005 | 8.0 | 8.0 | | v80 |
598 +----------+-------+-------+-----------+------------------------+
599 | 2003.NET | 7.1 | 7.1 | | v71 |
600 +----------+-------+-------+-----------+------------------------+
601 | 2002.NET | 7.0 | 7.0 | | v70 |
602 +----------+-------+-------+-----------+------------------------+
603 | 6.0 | 6.0 | 6.0 | | v60 |
604 +----------+-------+-------+-----------+------------------------+
607 SCons Implementation Notes
608 ==========================
610 Compiler Detection Logic
611 ------------------------
613 **WARNING: the compiler detection logic documentation below is likely out-of-date.**
615 In the future, the compiler detection logic documentation will be updated and integrated
616 into the current document format as appropriate.
620 This is the flow of the compiler detection logic:
622 External to MSCommon:
624 The Tool init modules, in their exists() routines, call -> msvc_exists(env)
626 At the moment, those modules are:
633 env may contain a version request in MSVC_VERSION, but this is not used
634 in the detection that follows from msvc_exists(), only in the later
635 batch that starts with a call to msvc_setup_env().
637 Internal to MSCommon/vc.py:
639 + MSCommon/vc.py:msvc_exists:
640 | vcs = cached_get_installed_vcs(env)
641 | returns True if vcs > 0
643 +-> MSCommon/vc.py:cached_get_installed_vcs:
644 | checks global if we've run previously, if so return it
645 | populate the global from -> get_installed_vcs(env)
647 +-> MSCommon/vc.py:get_installed_vcs:
648 | loop through "known" versions of msvc, granularity is maj.min
649 | check for product dir -> find_vc_pdir(env, ver)
651 +-> MSCommon/vc.py:find_vc_pdir:
652 | From the msvc-version to pdir mapping dict, get reg key base and value
653 | If value is none -> find_vc_pdir_vswhere(ver, env)
655 +-> MSCommon/vc.py:find_vc_pdir_vswhere:
656 | From the vc-version to VS-version mapping table get string
657 | Figure out where vswhere is -> msvc_find_vswhere()
658 | Use subprocess to call vswhere, return first line of match
660 | else get product directory from registry (<= 14.0)
662 | if we found one -> _check_cl_exists_in_vc_dir(env, pdir, ver)
664 +-> MSCommon/vc.py:_check_cl_exists_in_vc_dir:
665 | Figure out host/target pair
666 | if version > 14.0 get specific version by looking in
667 | pdir + Auxiliary/Build/Microsoft/VCToolsVersion/default.txt
668 | look for pdir + Tools/MSVC/{specver}/bin/host/target/cl.exe
669 | if 14.0 or less, "do older stuff"
671 All of this just got us a yes-no answer on whether /some/ msvc version
672 exists, but does populate __INSTALLED_VCS_RUN with all of the top-level
673 versions as noted for get_installed_vcs
677 Once a module's exists() has been called (or, in the case of
678 clang/clangxx, after the compiler has been detected by other means -
679 those still expect the rest of the msvc chain but not cl.exe)
680 the module's generate() function calls -> msvc_setup_env_once(env)
684 + MSCommon/vc.py:msvc_setup_env_once:
685 | checks for environment flag MSVC_SETUP_RUN
686 | if not, -> msvc_setup_env(env) and set flag
688 +-+ MSCommon/vc.py:msvc_setup_env:
689 | set ver from -> get_default_version(env)
691 +-+ MSCommon/vc.py:get_default_version:
692 | if no version specified in env.MSVC_VERSION:
693 | return first entry from -> cached_get_installed_vcs(env)
694 | else return requested version
696 | get script from MSVC_USE_SCRIPT if set to a filename
697 | -> script_env(script)
699 +-+ MSCommon/vc.py:script_env:
700 | return (possibly cached) script variables matching script arg
702 | else -> msvc_find_valid_batch_script(env, version)
704 +-+ MSCommon/vc.py:msvc_find_valid_batch_script:
705 | Build a list of plausible target values, and loop through
706 | look for host + target -> find_batch_file(env, ver, host, target)
708 +-+ MSCommon/vc.py:find_batch_file:
709 | call -> find_vc_pdir (see above)
710 | use the return to construct a version-biased batfile path, check
712 | if not found, try sdk scripts (unknown if this is still useful)
716 - For VS >= 2017, VS and VS are not 1:1, there can be many VC for one VS
717 - For vswhere-ready versions, detection does not proceed beyond the
718 product level ("2019") into individual "features" (individual msvc)
719 - As documented for MSVC_VERSION, compilers can only be requested if versions
720 are from the set in _VCVER, so 14.1 but not 14.16 or 14.16.27023
721 - Information found in the first pass (msvs_exists) isn't really
722 available anywhere except the cached version list, since we just
724 - Since msvc_exists chain of calls does not look at version, we
725 can proceed to compiler setup if *any* msvc was found, even if the
726 one requested wasn't found.