aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/backend/vs2010backend.py23
-rw-r--r--mesonbuild/coredata.py2
-rw-r--r--mesonbuild/mesonmain.py4
3 files changed, 28 insertions, 1 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
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 0d2af69..d3a1241 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -18,7 +18,7 @@ from .mesonlib import MesonException, commonpath
from .mesonlib import default_libdir, default_libexecdir, default_prefix
version = '0.40.0.dev1'
-backendlist = ['ninja', 'vs2010', 'vs2015', 'vs2017', 'xcode']
+backendlist = ['ninja', 'vs', 'vs2010', 'vs2015', 'vs2017', 'xcode']
class UserOption:
def __init__(self, name, description, choices):
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index 38c00a0..7db6310 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -145,6 +145,10 @@ If you want to change option values, use the mesonconf tool instead.'''
if self.options.backend == 'ninja':
from .backend import ninjabackend
g = ninjabackend.NinjaBackend(b)
+ elif self.options.backend == 'vs':
+ from .backend import vs2010backend
+ g = vs2010backend.autodetect_vs_version(b)
+ mlog.log('Auto detected Visual Studio backend:', mlog.bold(g.name))
elif self.options.backend == 'vs2010':
from .backend import vs2010backend
g = vs2010backend.Vs2010Backend(b)