mirror of
https://github.com/mesonbuild/meson.git
synced 2026-11-06 05:16:42 +00:00
This replaces all of the Apache blurbs at the start of each file with an `# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing uses to be consistent in capitalization, and to be placed above any copyright notices. This removes nearly 3000 lines of boilerplate from the project (only python files), which no developer cares to look at. SPDX is in common use, particularly in the Linux kernel, and is the recommended format for Meson's own `project(license: )` field
108 lines
4.7 KiB
Python
108 lines
4.7 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# Copyright 2012-2017 The Meson development team
|
|
|
|
from __future__ import annotations
|
|
|
|
import typing as T
|
|
|
|
from .. import coredata
|
|
from ..mesonlib import OptionKey
|
|
|
|
from .mixins.clike import CLikeCompiler
|
|
from .compilers import Compiler
|
|
from .mixins.gnu import GnuCompiler, gnu_common_warning_args, gnu_objc_warning_args
|
|
from .mixins.clang import ClangCompiler
|
|
|
|
if T.TYPE_CHECKING:
|
|
from ..programs import ExternalProgram
|
|
from ..envconfig import MachineInfo
|
|
from ..environment import Environment
|
|
from ..linkers.linkers import DynamicLinker
|
|
from ..mesonlib import MachineChoice
|
|
|
|
class ObjCPPCompiler(CLikeCompiler, Compiler):
|
|
|
|
language = 'objcpp'
|
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,
|
|
is_cross: bool, info: 'MachineInfo',
|
|
exe_wrap: T.Optional['ExternalProgram'],
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
full_version: T.Optional[str] = None):
|
|
Compiler.__init__(self, ccache, exelist, version, for_machine, info,
|
|
is_cross=is_cross, full_version=full_version,
|
|
linker=linker)
|
|
CLikeCompiler.__init__(self, exe_wrap)
|
|
|
|
@staticmethod
|
|
def get_display_language() -> str:
|
|
return 'Objective-C++'
|
|
|
|
def sanity_check(self, work_dir: str, environment: 'Environment') -> None:
|
|
code = '#import<stdio.h>\nclass MyClass;int main(void) { return 0; }\n'
|
|
return self._sanity_check_impl(work_dir, environment, 'sanitycheckobjcpp.mm', code)
|
|
|
|
|
|
class GnuObjCPPCompiler(GnuCompiler, ObjCPPCompiler):
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,
|
|
is_cross: bool, info: 'MachineInfo',
|
|
exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
defines: T.Optional[T.Dict[str, str]] = None,
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
full_version: T.Optional[str] = None):
|
|
ObjCPPCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
|
info, exe_wrapper, linker=linker, full_version=full_version)
|
|
GnuCompiler.__init__(self, defines)
|
|
default_warn_args = ['-Wall', '-Winvalid-pch']
|
|
self.warn_args = {'0': [],
|
|
'1': default_warn_args,
|
|
'2': default_warn_args + ['-Wextra'],
|
|
'3': default_warn_args + ['-Wextra', '-Wpedantic'],
|
|
'everything': (default_warn_args + ['-Wextra', '-Wpedantic'] +
|
|
self.supported_warn_args(gnu_common_warning_args) +
|
|
self.supported_warn_args(gnu_objc_warning_args))}
|
|
|
|
|
|
class ClangObjCPPCompiler(ClangCompiler, ObjCPPCompiler):
|
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,
|
|
is_cross: bool, info: 'MachineInfo',
|
|
exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
defines: T.Optional[T.Dict[str, str]] = None,
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
full_version: T.Optional[str] = None):
|
|
ObjCPPCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
|
info, exe_wrapper, linker=linker, full_version=full_version)
|
|
ClangCompiler.__init__(self, defines)
|
|
default_warn_args = ['-Wall', '-Winvalid-pch']
|
|
self.warn_args = {'0': [],
|
|
'1': default_warn_args,
|
|
'2': default_warn_args + ['-Wextra'],
|
|
'3': default_warn_args + ['-Wextra', '-Wpedantic'],
|
|
'everything': ['-Weverything']}
|
|
|
|
def get_options(self) -> 'coredata.MutableKeyedOptionDictType':
|
|
opts = super().get_options()
|
|
opts.update({
|
|
OptionKey('std', machine=self.for_machine, lang='cpp'): coredata.UserComboOption(
|
|
'C++ language standard to use',
|
|
['none', 'c++98', 'c++11', 'c++14', 'c++17', 'c++20', 'c++2b',
|
|
'gnu++98', 'gnu++11', 'gnu++14', 'gnu++17', 'gnu++20',
|
|
'gnu++2b'],
|
|
'none',
|
|
)
|
|
})
|
|
return opts
|
|
|
|
def get_option_compile_args(self, options: 'coredata.KeyedOptionDictType') -> T.List[str]:
|
|
args = []
|
|
std = options[OptionKey('std', machine=self.for_machine, lang='cpp')]
|
|
if std.value != 'none':
|
|
args.append('-std=' + std.value)
|
|
return args
|
|
|
|
|
|
class AppleClangObjCPPCompiler(ClangObjCPPCompiler):
|
|
|
|
"""Handle the differences between Apple's clang and vanilla clang."""
|