diff options
author | Naveen M K <naveen@syrusdark.website> | 2021-05-28 21:13:52 +0530 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2021-05-28 15:16:37 -0400 |
commit | 7ec52679391f2482f8dda2ebfc7f79bd6c89a071 (patch) | |
tree | 915999041a373ac2f8b8c3f1a92d0d75ec51bf9f | |
parent | a9959a385990bb9760cfdb5fda9a6bc6fb7725fe (diff) | |
download | meson-7ec52679391f2482f8dda2ebfc7f79bd6c89a071.zip meson-7ec52679391f2482f8dda2ebfc7f79bd6c89a071.tar.gz meson-7ec52679391f2482f8dda2ebfc7f79bd6c89a071.tar.bz2 |
Find Visual Studio Build Tools 2019
Got the Idea from setuptools
https://github.com/pypa/setuptools/blob/a5131f0b82e098da6c07a03a47f36f3a52f73fb6/setuptools/msvc.py#L176
-rw-r--r-- | mesonbuild/mesonmain.py | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index f5be6c3..e79ab22 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -64,21 +64,31 @@ def setup_vsenv(): if shutil.which('cl.exe'): return - bat_locator_bin = r'c:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' - if not os.path.exists(bat_locator_bin): + root = os.environ.get("ProgramFiles(x86)") or os.environ.get("ProgramFiles") + bat_locator_bin = pathlib.Path(root, 'Microsoft Visual Studio/Installer/vswhere.exe') + if not bat_locator_bin.exists(): return - bat_json = subprocess.check_output([bat_locator_bin, '-latest', '-format', 'json']) + bat_json = subprocess.check_output( + [ + str(bat_locator_bin), + '-latest', + '-prerelease', + '-requiresAny', + '-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64', + '-requires', 'Microsoft.VisualStudio.Workload.WDExpress', + '-products', '*', + '-format', + 'json' + ] + ) bat_info = json.loads(bat_json) if not bat_info: - bat_json = subprocess.check_output([bat_locator_bin, '-prerelease', '-format', 'json']) - bat_info = json.loads(bat_json) - if not bat_info: # VS installer instelled but not VS itself maybe? return print('Activating VS', bat_info[0]['catalog']['productDisplayVersion']) - bat_root = bat_info[0]['installationPath'] - bat_path = bat_root + r'\VC\Auxiliary\Build\vcvars64.bat' - if not os.path.exists(bat_path): + bat_root = pathlib.Path(bat_info[0]['installationPath']) + bat_path = bat_root / 'VC/Auxiliary/Build/vcvars64.bat' + if not bat_path.exists(): return bat_file = pathlib.Path.home() / 'vsdetect.bat' |