| 1 |
# SPDX-License-Identifier: Apache-2.0 |
| 2 |
# Copyright 2014-2016 The Meson development team |
| 3 |
|
| 4 |
from __future__ import annotations |
| 5 |
|
| 6 |
import os |
| 7 |
import typing as T |
| 8 |
import xml.etree.ElementTree as ET |
| 9 |
|
| 10 |
from .vs2010backend import Vs2010Backend |
| 11 |
from ..mesonlib import MesonException |
| 12 |
|
| 13 |
if T.TYPE_CHECKING: |
| 14 |
from ..arglist import CompilerArgs |
| 15 |
from ..build import Build |
| 16 |
from ..compilers.compilers import Language |
| 17 |
|
| 18 |
|
| 19 |
class Vs2017Backend(Vs2010Backend): |
| 20 |
|
| 21 |
name = 'vs2017' |
| 22 |
|
| 23 |
def __init__(self, build: T.Optional[Build]): |
| 24 |
super().__init__(build) |
| 25 |
self.vs_version = '2017' |
| 26 |
self.sln_file_version = '12.00' |
| 27 |
self.sln_version_comment = '15' |
| 28 |
|
| 29 |
def detect_toolset(self) -> None: |
| 30 |
# We assume that host == build |
| 31 |
if self.environment is not None: |
| 32 |
comps = self.environment.coredata.compilers.host |
| 33 |
if comps: |
| 34 |
if comps and all(c.id == 'clang-cl' for c in comps.values()): |
| 35 |
self.platform_toolset = 'llvm' |
| 36 |
elif comps and all(c.id == 'intel-cl' for c in comps.values()): |
| 37 |
c = list(comps.values())[0] |
| 38 |
if c.version.startswith('19'): |
| 39 |
self.platform_toolset = 'Intel C++ Compiler 19.0' |
| 40 |
else: |
| 41 |
# We don't have support for versions older than 2019 right now. |
| 42 |
raise MesonException('There is currently no support for ICL before 19, patches welcome.') |
| 43 |
if self.platform_toolset is None: |
| 44 |
self.platform_toolset = 'v141' |
| 45 |
# WindowsSDKVersion should be set by command prompt. |
| 46 |
sdk_version = os.environ.get('WindowsSDKVersion', None) |
| 47 |
if sdk_version: |
| 48 |
self.windows_target_platform_version = sdk_version.rstrip('\\') |
| 49 |
|
| 50 |
def generate_debug_information(self, link: ET.Element) -> None: |
| 51 |
# valid values for vs2017 is 'false', 'true', 'DebugFastLink', 'DebugFull' |
| 52 |
ET.SubElement(link, 'GenerateDebugInformation').text = 'DebugFull' |
| 53 |
|
| 54 |
def generate_lang_standard_info(self, file_args: T.Dict[Language, CompilerArgs], clconf: ET.Element) -> None: |
| 55 |
if 'cpp' in file_args: |
| 56 |
optargs = [x for x in file_args['cpp'] if x.startswith('/std:c++')] |
| 57 |
if optargs: |
| 58 |
ET.SubElement(clconf, 'LanguageStandard').text = optargs[0].replace("/std:c++", "stdcpp") |
| 59 |
if 'c' in file_args: |
| 60 |
optargs = [x for x in file_args['c'] if x.startswith('/std:c')] |
| 61 |
if optargs: |
| 62 |
ET.SubElement(clconf, 'LanguageStandard_C').text = optargs[0].replace("/std:c", "stdc") |