diff options
author | Crend King <975235+CrendKing@users.noreply.github.com> | 2021-11-10 04:11:31 -0800 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2021-11-21 08:08:11 -0500 |
commit | 809792c2233ee0da4127d77f73c3bf715128d33c (patch) | |
tree | 30b94948ff00790e360c5128250b7536d3712ec4 /mesonbuild | |
parent | 59245101881ec5e24bc61ec35576ad376a769f40 (diff) | |
download | meson-809792c2233ee0da4127d77f73c3bf715128d33c.zip meson-809792c2233ee0da4127d77f73c3bf715128d33c.tar.gz meson-809792c2233ee0da4127d77f73c3bf715128d33c.tar.bz2 |
Support Visual Studio 2022 backend
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/backends.py | 3 | ||||
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 4 | ||||
-rw-r--r-- | mesonbuild/backend/vs2022backend.py | 57 | ||||
-rw-r--r-- | mesonbuild/cmake/common.py | 1 | ||||
-rw-r--r-- | mesonbuild/coredata.py | 2 |
5 files changed, 66 insertions, 1 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 1d04c91..6c15678 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -259,6 +259,9 @@ def get_backend_from_name(backend: str, build: T.Optional[build.Build] = None, i elif backend == 'vs2019': from . import vs2019backend return vs2019backend.Vs2019Backend(build, interpreter) + elif backend == 'vs2022': + from . import vs2022backend + return vs2022backend.Vs2022Backend(build, interpreter) elif backend == 'xcode': from . import xcodebackend return xcodebackend.XCodeBackend(build, interpreter) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 8ed2428..4597a5a 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -57,6 +57,10 @@ def autodetect_vs_version(build: T.Optional[build.Build], interpreter: T.Optiona 'Visual Studio\\2019' in vs_install_dir: from mesonbuild.backend.vs2019backend import Vs2019Backend return Vs2019Backend(build, interpreter) + if vs_version == '17.0' or 'Visual Studio 22' in vs_install_dir or \ + 'Visual Studio\\2022' in vs_install_dir: + from mesonbuild.backend.vs2022backend import Vs2022Backend + return Vs2022Backend(build, interpreter) if 'Visual Studio 10.0' in vs_install_dir: return Vs2010Backend(build, interpreter) raise MesonException('Could not detect Visual Studio using VisualStudioVersion: {!r} or VSINSTALLDIR: {!r}!\n' diff --git a/mesonbuild/backend/vs2022backend.py b/mesonbuild/backend/vs2022backend.py new file mode 100644 index 0000000..19ad090 --- /dev/null +++ b/mesonbuild/backend/vs2022backend.py @@ -0,0 +1,57 @@ +# Copyright 2014-2021 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 +import typing as T +import xml.etree.ElementTree as ET + +from .vs2010backend import Vs2010Backend +from ..interpreter import Interpreter +from ..build import Build + + +class Vs2022Backend(Vs2010Backend): + def __init__(self, build: T.Optional[Build], interpreter: T.Optional[Interpreter]): + super().__init__(build, interpreter) + self.name = 'vs2022' + if self.environment is not None: + comps = self.environment.coredata.compilers.host + if comps and all(c.id == 'clang-cl' for c in comps.values()): + self.platform_toolset = 'ClangCL' + elif comps and all(c.id == 'intel-cl' for c in comps.values()): + c = list(comps.values())[0] + if c.version.startswith('19'): + self.platform_toolset = 'Intel C++ Compiler 19.0' + # We don't have support for versions older than 2022 right now. + if not self.platform_toolset: + self.platform_toolset = 'v143' + self.vs_version = '2022' + # WindowsSDKVersion should be set by command prompt. + sdk_version = os.environ.get('WindowsSDKVersion', None) + if sdk_version: + self.windows_target_platform_version = sdk_version.rstrip('\\') + + def generate_debug_information(self, link): + # valid values for vs2022 is 'false', 'true', 'DebugFastLink', 'DebugFull' + ET.SubElement(link, 'GenerateDebugInformation').text = 'DebugFull' + + def generate_lang_standard_info(self, file_args, clconf): + if 'cpp' in file_args: + optargs = [x for x in file_args['cpp'] if x.startswith('/std:c++')] + if optargs: + ET.SubElement(clconf, 'LanguageStandard').text = optargs[0].replace("/std:c++", "stdcpp") + if 'c' in file_args: + optargs = [x for x in file_args['c'] if x.startswith('/std:c')] + if optargs: + ET.SubElement(clconf, 'LanguageStandard_C').text = optargs[0].replace("/std:c", "stdc") diff --git a/mesonbuild/cmake/common.py b/mesonbuild/cmake/common.py index 5cc154c..f6ba5ec 100644 --- a/mesonbuild/cmake/common.py +++ b/mesonbuild/cmake/common.py @@ -44,6 +44,7 @@ backend_generator_map = { 'vs2015': 'Visual Studio 14 2015', 'vs2017': 'Visual Studio 15 2017', 'vs2019': 'Visual Studio 16 2019', + 'vs2022': 'Visual Studio 17 2022', } blacklist_cmake_defs = [ diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 175b833..f444cf1 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -46,7 +46,7 @@ if T.TYPE_CHECKING: # Check major_versions_differ() if changing versioning scheme. version = '0.60.99' -backendlist = ['ninja', 'vs', 'vs2010', 'vs2012', 'vs2013', 'vs2015', 'vs2017', 'vs2019', 'xcode'] +backendlist = ['ninja', 'vs', 'vs2010', 'vs2012', 'vs2013', 'vs2015', 'vs2017', 'vs2019', 'vs2022', 'xcode'] default_yielding = False |