diff options
author | Nicolas Schneider <nioncode+git@gmail.com> | 2017-03-23 10:34:32 +0100 |
---|---|---|
committer | Nicolas Schneider <nioncode+git@gmail.com> | 2017-03-23 10:34:32 +0100 |
commit | 92ed60729070c5b94c34ab24b1553d40978b645d (patch) | |
tree | ae1cba87e82446ae3b143b85da63ad59041fcbcf /mesonbuild/backend/vs2010backend.py | |
parent | 776de065a8e1bfe94938d535bdf06c1cad9dc28b (diff) | |
download | meson-92ed60729070c5b94c34ab24b1553d40978b645d.zip meson-92ed60729070c5b94c34ab24b1553d40978b645d.tar.gz meson-92ed60729070c5b94c34ab24b1553d40978b645d.tar.bz2 |
add 'vs' backend that automatically chooses between the vs backends
For newer VS versions, we can simply rely on 'VisualStudioVersion' being
set in the environment.
For VS2010, we fall back to check 'VSINSTALLDIR' for the version string.
If the backend can not be auto detected, we raise an exception to make the
user choose an explicit backend.
We also print the detected backend to the meson log.
Diffstat (limited to 'mesonbuild/backend/vs2010backend.py')
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 6b4859d..a3af95f 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -27,6 +27,29 @@ from ..compilers import CompilerArgs from ..mesonlib import MesonException, File 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 '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)) + def split_o_flags_args(args): """ Splits any /O args and returns them. Does not take care of flags overriding |