Skip to content

Commit 3b95dd6

Browse files
committed
Refactor vswhere executable support and detection.
vswhere changes: * Split the current vswhere paths list into two lists: * the visual studio installer locations, * the package manager locations. * Add additional user vswhere priority groups: * before the vs installer locations [high priority], * after the vs installer locations [default priority], and * after the package manager locations [low priority]. * Adjust tests for vswhere path list changes accordingly. * Add vswhere location functions to: * register user vswhere executable paths by priority, * get the currently configured vswhere executable location, * freeze the vswhere executable location used for detection. * Assign the environment VSWHERE construction variable in Tool/MSCommon/vc.py. * Remove the assignment of the environment VSWHERE construction variable in Tool/msvc.py * Update the test suite function signature for finding the msvc product directory with vswhere. * Freeze the vswhere executable in the following functions before the cache is evaluated which will raise an exception if the vswhere executable has changed since the initial detection (if necessary): * MSCommon.vc.get_installed_visual_studios, * MSCommon.vc.find_vc_pdir, * MSCommon.vc.msvc_setup_env, * MSCommon.vs.get_installed_visual_studios
1 parent 1fab595 commit 3b95dd6

17 files changed

+608
-320
lines changed

CHANGES.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,16 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
8585
of the results from all vswhere executables). There is a single invocation for
8686
each vswhere executable that processes the output for all installations. Prior
8787
implementations called the vswhere executable for each supported msvc version.
88-
- Previously, the installed vcs and visual studios lists were constructed once and
89-
cached at runtime. If a vswhere executable was specified via the construction
90-
variable VSWHERE and found additional msvc installations, the new installations
91-
were not reflected in the installed vcs and visual studios lists. Now, when a
92-
user-specified vswhere executable finds new msvc installations, internal runtime
93-
caches are cleared and the installed vcs and visual studios lists are reconstructed
94-
on their next retrieval.
88+
- The vswhere executable is frozen upon initial detection. Specifying a different
89+
vswhere executable via the construction variable VSWHERE after the initial
90+
detection now results in an exception. Multiple bugs in the implementation of
91+
specifying a vswhere executable via the construction variable VSWHERE have been
92+
fixed. Previously, when a user specified vswhere executable detects new msvc
93+
installations after the initial detection, the internal msvc installation cache
94+
and the default msvc version based on the initial detection are no longer valid.
95+
For example, when no vswhere executable is found for the initial detection
96+
and then later an environment is constructed with a user specified vswhere
97+
executable that detects new msvc installations.
9598

9699
From Thaddeus Crews:
97100
- Implemented SCons.Util.sctyping as a safe means of hinting complex types. Currently

RELEASE.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,16 @@ FIXES
7575
is now selected before a Visual C++ For Python edition. Prior to this change,
7676
Visual C++ For Python was selected before a full development edition when both
7777
editions are installed.
78-
- MSVC: The installed vcs and visual studios lists were constructed and cached
79-
during their initial invocations. If a vswhere executable was specified via the
80-
construction variable VSWHERE and found additional msvc installations, the new
81-
installations were not reflected in the cached installed vcs and visual studios
82-
lists. Now, when a user-specified vswhere executable finds new msvc installations,
83-
the installed vcs and visual studios lists are cleared and reconstructed on their
84-
next retrieval.
78+
- The vswhere executable is frozen upon initial detection. Specifying a different
79+
vswhere executable via the construction variable VSWHERE after the initial
80+
detection now results in an exception. Multiple bugs in the implementation of
81+
specifying a vswhere executable via the construction variable VSWHERE have been
82+
fixed. Previously, when a user specified vswhere executable detects new msvc
83+
installations after the initial detection, the internal msvc installation cache
84+
and the default msvc version based on the initial detection are no longer valid.
85+
For example, when no vswhere executable is found for the initial detection
86+
and then later an environment is constructed with a user specified vswhere
87+
executable that detects new msvc installations.
8588
- On Windows platform, when collecting command output (Configure checks),
8689
make sure decoding of bytes doesn't fail.
8790
- Documentation indicated that both Pseudo() and env.Pseudo() were usable,

SCons/Tool/MSCommon/MSVC/Util.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@
3737

3838
from . import Config
3939

40+
41+
# call _initialize method upon class definition completion
42+
43+
class AutoInitialize:
44+
def __init_subclass__(cls, **kwargs):
45+
super().__init_subclass__(**kwargs)
46+
if hasattr(cls, '_initialize') and callable(getattr(cls, '_initialize', None)):
47+
cls._initialize()
48+
4049
# path utilities
4150

4251
# windows drive specification (e.g., 'C:')

SCons/Tool/MSCommon/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
msvc_toolset_versions,
4646
msvc_toolset_versions_spectre,
4747
msvc_query_version_toolset,
48+
vswhere_register_executable,
49+
vswhere_get_executable,
50+
vswhere_freeze_executable,
4851
)
4952

5053
from SCons.Tool.MSCommon.vs import ( # noqa: F401
@@ -78,7 +81,9 @@
7881
MSVCUnsupportedHostArch,
7982
MSVCUnsupportedTargetArch,
8083
MSVCScriptNotFound,
84+
MSVCUseScriptError,
8185
MSVCUseSettingsError,
86+
VSWhereUserError,
8287
)
8388

8489
from .MSVC.Util import ( # noqa: F401

0 commit comments

Comments
 (0)