Fail Visual Studio version detection if VSINSTALLDIR is not set

The Visual Studio Developer Command Prompt always sets the VSINSTALLDIR
environment variable. If not, we probably have a broken environment and
won't get very far anyway.
pull/2849/head
Gabríel Arthúr Pétursson 7 years ago
parent 8fb7d9261a
commit c8355c9ffa
  1. 7
      mesonbuild/backend/vs2010backend.py

@ -29,10 +29,9 @@ from ..environment import Environment
def autodetect_vs_version(build): def autodetect_vs_version(build):
vs_version = os.getenv('VisualStudioVersion', None) vs_version = os.getenv('VisualStudioVersion', None)
vs_install_dir = os.getenv('VSINSTALLDIR', None) vs_install_dir = os.getenv('VSINSTALLDIR', None)
if not vs_version and not vs_install_dir: if not vs_install_dir:
raise MesonException('Could not detect Visual Studio: VisualStudioVersion and VSINSTALLDIR are unset!\n' raise MesonException('Could not detect Visual Studio: Environment variable VSINSTALLDIR is not set!\n'
'Are we inside a Visual Studio build environment? ' 'Are you running meson from the Visual Studio Developer Command Prompt?')
'You can also try specifying the exact backend to use.')
# VisualStudioVersion is set since Visual Studio 12.0, but sometimes # VisualStudioVersion is set since Visual Studio 12.0, but sometimes
# vcvarsall.bat doesn't set it, so also use VSINSTALLDIR # vcvarsall.bat doesn't set it, so also use VSINSTALLDIR
if vs_version == '14.0' or 'Visual Studio 14' in vs_install_dir: if vs_version == '14.0' or 'Visual Studio 14' in vs_install_dir:

Loading…
Cancel
Save