diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-06-09 19:14:58 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-06-09 20:21:01 +0530 |
commit | 130076642974e62bdda3a6bf97317323cc8331f7 (patch) | |
tree | a6c2cd0ff24632d8cfd940e530106ab1a5b774ba | |
parent | 38716f0fcb03c73ae1279036913e5b0ac41528a6 (diff) | |
download | meson-130076642974e62bdda3a6bf97317323cc8331f7.zip meson-130076642974e62bdda3a6bf97317323cc8331f7.tar.gz meson-130076642974e62bdda3a6bf97317323cc8331f7.tar.bz2 |
vs: Always check VSINSTALLDIR in case VisualStudioVersion is unset
This happened on the CI, so it could happen on people's machines too:
https://ci.appveyor.com/project/jpakkane/meson/build/2870/job/p2n70hg01vp3dkgl
https://ci.appveyor.com/project/jpakkane/meson/build/2870/job/7ifh64mi1999guxt
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index fafde8f..d4a7a19 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -29,26 +29,24 @@ from ..environment import Environment def autodetect_vs_version(build): vs_version = os.getenv('VisualStudioVersion', None) - if vs_version: - if vs_version == '14.0': - from mesonbuild.backend.vs2015backend import Vs2015Backend - return Vs2015Backend(build) - if vs_version == '15.0': - from mesonbuild.backend.vs2017backend import Vs2017Backend - return Vs2017Backend(build) - raise MesonException('Could not detect Visual Studio (unknown Visual Studio version: "{}")!\n' - 'Please specify the exact backend to use.'.format(vs_version)) - vs_install_dir = os.getenv('VSINSTALLDIR', None) - if not vs_install_dir: - raise MesonException('Could not detect Visual Studio (neither VisualStudioVersion nor VSINSTALLDIR set in ' - 'environment)!\nPlease specify the exact backend to use.') - + if not vs_version and not vs_install_dir: + raise MesonException('Could not detect Visual Studio: VisualStudioVersion and VSINSTALLDIR are unset!\n' + 'Are we inside a Visual Studio build environment? ' + 'You can also try specifying the exact backend to use.') + # VisualStudioVersion is set since Visual Studio 12.0, but sometimes + # vcvarsall.bat doesn't set it, so also use VSINSTALLDIR + if vs_version == '14.0' or 'Visual Studio 14' in vs_install_dir: + from mesonbuild.backend.vs2015backend import Vs2015Backend + return Vs2015Backend(build) + if vs_version == '15.0' or 'Visual Studio 17' in vs_install_dir or \ + 'Visual Studio\\2017' in vs_install_dir: + from mesonbuild.backend.vs2017backend import Vs2017Backend + return Vs2017Backend(build) if 'Visual Studio 10.0' in vs_install_dir: return Vs2010Backend(build) - - raise MesonException('Could not detect Visual Studio (unknown VSINSTALLDIR: "{}")!\n' - 'Please specify the exact backend to use.'.format(vs_install_dir)) + raise MesonException('Could not detect Visual Studio using VisualStudioVersion: {!r} or VSINSTALLDIR: {!r}!\n' + 'Please specify the exact backend to use.'.format(vs_version, vs_install_dir)) def split_o_flags_args(args): """ |