diff options
Diffstat (limited to 'mesonbuild/mesonlib/vsenv.py')
-rw-r--r-- | mesonbuild/mesonlib/vsenv.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/mesonbuild/mesonlib/vsenv.py b/mesonbuild/mesonlib/vsenv.py index 2ba2b90..fcb0c42 100644 --- a/mesonbuild/mesonlib/vsenv.py +++ b/mesonbuild/mesonlib/vsenv.py @@ -26,15 +26,16 @@ def _setup_vsenv(force: bool) -> bool: return False if os.environ.get('OSTYPE') == 'cygwin': return False - if 'Visual Studio' in os.environ['PATH']: - return False - # VSINSTALL is set when running setvars from a Visual Studio installation - # Tested with Visual Studio 2012 and 2017 - if 'VSINSTALLDIR' in os.environ: - return False - # Check explicitly for cl when on Windows - if shutil.which('cl.exe'): - return False + if 'MESON_FORCE_VSENV_FOR_UNITTEST' not in os.environ: + if 'Visual Studio' in os.environ['PATH']: + return False + # VSINSTALL is set when running setvars from a Visual Studio installation + # Tested with Visual Studio 2012 and 2017 + if 'VSINSTALLDIR' in os.environ: + return False + # Check explicitly for cl when on Windows + if shutil.which('cl.exe'): + return False if not force: if shutil.which('cc'): return False @@ -56,6 +57,7 @@ def _setup_vsenv(force: bool) -> bool: '-prerelease', '-requiresAny', '-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64', + '-requires', 'Microsoft.VisualStudio.Workload.WDExpress', '-products', '*', '-utf8', '-format', @@ -71,6 +73,9 @@ def _setup_vsenv(force: bool) -> bool: bat_path = bat_root / 'VC/Auxiliary/Build/vcvarsx86_arm64.bat' else: bat_path = bat_root / 'VC/Auxiliary/Build/vcvars64.bat' + # if VS is not found try VS Express + if not bat_path.exists(): + bat_path = bat_root / 'VC/Auxiliary/Build/vcvarsx86_amd64.bat' if not bat_path.exists(): raise MesonException(f'Could not find {bat_path}') |