diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-03-24 19:10:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-24 19:10:31 +0200 |
commit | 60034e87b20e71dcaa4fb795965d8477910c733c (patch) | |
tree | b9415672429d031355df2b7536df719b25dc69d3 /mesonbuild | |
parent | 53795d89df48ca722b018ff8720669deb6209be4 (diff) | |
parent | 92ed60729070c5b94c34ab24b1553d40978b645d (diff) | |
download | meson-60034e87b20e71dcaa4fb795965d8477910c733c.zip meson-60034e87b20e71dcaa4fb795965d8477910c733c.tar.gz meson-60034e87b20e71dcaa4fb795965d8477910c733c.tar.bz2 |
Merge pull request #1491 from nioncode/vs2017
VS2017 backend
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 32 | ||||
-rw-r--r-- | mesonbuild/backend/vs2017backend.py | 27 | ||||
-rw-r--r-- | mesonbuild/coredata.py | 2 | ||||
-rw-r--r-- | mesonbuild/mesonmain.py | 7 |
4 files changed, 67 insertions, 1 deletions
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 82c6463..07306aa 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 @@ -62,6 +85,7 @@ class Vs2010Backend(backends.Backend): self.sources_conflicts = {} self.platform_toolset = None self.vs_version = '2010' + self.windows_target_platform_version = None def object_filename_from_source(self, target, source): basename = os.path.basename(source.fname) @@ -354,6 +378,8 @@ class Vs2010Backend(backends.Backend): p.text = self.platform pname = ET.SubElement(globalgroup, 'ProjectName') pname.text = project_name + if self.windows_target_platform_version: + ET.SubElement(globalgroup, 'WindowsTargetPlatformVersion').text = self.windows_target_platform_version ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.Default.props') type_config = ET.SubElement(root, 'PropertyGroup', Label='Configuration') ET.SubElement(type_config, 'ConfigurationType') @@ -598,6 +624,8 @@ class Vs2010Backend(backends.Backend): p.text = self.platform pname = ET.SubElement(globalgroup, 'ProjectName') pname.text = project_name + if self.windows_target_platform_version: + ET.SubElement(globalgroup, 'WindowsTargetPlatformVersion').text = self.windows_target_platform_version ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.Default.props') # Start configuration type_config = ET.SubElement(root, 'PropertyGroup', Label='Configuration') @@ -1015,6 +1043,8 @@ class Vs2010Backend(backends.Backend): p.text = self.platform pname = ET.SubElement(globalgroup, 'ProjectName') pname.text = project_name + if self.windows_target_platform_version: + ET.SubElement(globalgroup, 'WindowsTargetPlatformVersion').text = self.windows_target_platform_version ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.Default.props') type_config = ET.SubElement(root, 'PropertyGroup', Label='Configuration') ET.SubElement(type_config, 'ConfigurationType').text = "Utility" @@ -1094,6 +1124,8 @@ if %%errorlevel%% neq 0 goto :VCEnd''' p.text = self.platform pname = ET.SubElement(globalgroup, 'ProjectName') pname.text = project_name + if self.windows_target_platform_version: + ET.SubElement(globalgroup, 'WindowsTargetPlatformVersion').text = self.windows_target_platform_version ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.Default.props') type_config = ET.SubElement(root, 'PropertyGroup', Label='Configuration') ET.SubElement(type_config, 'ConfigurationType') diff --git a/mesonbuild/backend/vs2017backend.py b/mesonbuild/backend/vs2017backend.py new file mode 100644 index 0000000..8301790 --- /dev/null +++ b/mesonbuild/backend/vs2017backend.py @@ -0,0 +1,27 @@ +# Copyright 2014-2016 The Meson development team + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from .vs2010backend import Vs2010Backend + + +class Vs2017Backend(Vs2010Backend): + def __init__(self, build): + super().__init__(build) + self.name = 'vs2017' + self.platform_toolset = 'v141' + self.vs_version = '2017' + # WindowsSDKVersion should be set by command prompt. + self.windows_target_platform_version = os.getenv('WindowsSDKVersion', None) diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index e88cdc8..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', '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 031486c..7db6310 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -145,12 +145,19 @@ 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) elif self.options.backend == 'vs2015': from .backend import vs2015backend g = vs2015backend.Vs2015Backend(b) + elif self.options.backend == 'vs2017': + from .backend import vs2017backend + g = vs2017backend.Vs2017Backend(b) elif self.options.backend == 'xcode': from .backend import xcodebackend g = xcodebackend.XCodeBackend(b) |