Merge pull request #1491 from nioncode/vs2017

VS2017 backend
pull/1513/head
Jussi Pakkanen 8 years ago committed by GitHub
commit 60034e87b2
  1. 21
      .appveyor.yml
  2. 32
      mesonbuild/backend/vs2010backend.py
  3. 27
      mesonbuild/backend/vs2017backend.py
  4. 2
      mesonbuild/coredata.py
  5. 7
      mesonbuild/mesonmain.py

@ -20,6 +20,16 @@ environment:
compiler: msvc2015
backend: vs2015
- arch: x86
compiler: msvc2017
backend: ninja
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- arch: x86
compiler: msvc2017
backend: vs2017
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- arch: x64
compiler: msvc2015
backend: ninja
@ -28,6 +38,16 @@ environment:
compiler: msvc2015
backend: vs2015
- arch: x64
compiler: msvc2017
backend: ninja
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- arch: x64
compiler: msvc2017
backend: vs2017
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
platform:
- x64
@ -43,6 +63,7 @@ install:
- cmd: echo Using Python at %MESON_PYTHON_PATH%
- cmd: if %compiler%==msvc2010 ( call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" %arch% )
- cmd: if %compiler%==msvc2015 ( call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %arch% )
- cmd: if %compiler%==msvc2017 ( call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" -arch=%arch% )
build_script:
- cmd: echo No build step.

@ -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')

@ -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)

@ -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):

@ -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)

Loading…
Cancel
Save