diff options
| author | Jussi Pakkanen <jpakkane@gmail.com> | 2025-01-28 23:12:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-28 23:12:18 +0200 |
| commit | b55cef0c3bf047591ee9a3e9503c530cf726deab (patch) | |
| tree | e9771265e2c83ff6d262561f90d18257cf4555ff /mesonbuild/compilers/objcpp.py | |
| parent | 7bcf38de60afd5ef9f8bc52ea67e6cb693c3d8a3 (diff) | |
| parent | 1eaab0253bea69432d69a1eddab377fbbd9ed74d (diff) | |
| download | meson-b55cef0c3bf047591ee9a3e9503c530cf726deab.tar.gz | |
Merge pull request #13642 from dcbaker/submit/fix-objc-standards
Support lists for ObjC and ObjC++ standards
Diffstat (limited to 'mesonbuild/compilers/objcpp.py')
| -rw-r--r-- | mesonbuild/compilers/objcpp.py | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py index 973d7bb0c..de968be42 100644 --- a/mesonbuild/compilers/objcpp.py +++ b/mesonbuild/compilers/objcpp.py @@ -5,13 +5,14 @@ from __future__ import annotations import typing as T -from .. import options -from ..options import OptionKey +from ..options import OptionKey, UserStdOption -from .mixins.clike import CLikeCompiler +from .cpp import ALL_STDS from .compilers import Compiler -from .mixins.gnu import GnuCompiler, gnu_common_warning_args, gnu_objc_warning_args -from .mixins.clang import ClangCompiler +from .mixins.apple import AppleCPPStdsMixin +from .mixins.gnu import GnuCompiler, GnuCPPStds, gnu_common_warning_args, gnu_objc_warning_args +from .mixins.clang import ClangCompiler, ClangCPPStds +from .mixins.clike import CLikeCompiler if T.TYPE_CHECKING: from .. import coredata @@ -20,6 +21,7 @@ if T.TYPE_CHECKING: from ..linkers.linkers import DynamicLinker from ..mesonlib import MachineChoice + class ObjCPPCompiler(CLikeCompiler, Compiler): language = 'objcpp' @@ -41,8 +43,21 @@ class ObjCPPCompiler(CLikeCompiler, Compiler): code = '#import<stdio.h>\nclass MyClass;int main(void) { return 0; }\n' return self._sanity_check_impl(work_dir, environment, 'sanitycheckobjcpp.mm', code) + def form_compileropt_key(self, basename: str) -> OptionKey: + if basename == 'std': + return OptionKey(f'cpp_{basename}', machine=self.for_machine) + return super().form_compileropt_key(basename) -class GnuObjCPPCompiler(GnuCompiler, ObjCPPCompiler): + def get_options(self) -> coredata.MutableKeyedOptionDictType: + opts = super().get_options() + key = self.form_compileropt_key('std') + opts.update({ + key: UserStdOption('cpp', ALL_STDS), + }) + return opts + + +class GnuObjCPPCompiler(GnuCPPStds, GnuCompiler, ObjCPPCompiler): def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool, info: 'MachineInfo', defines: T.Optional[T.Dict[str, str]] = None, @@ -60,8 +75,15 @@ class GnuObjCPPCompiler(GnuCompiler, ObjCPPCompiler): self.supported_warn_args(gnu_common_warning_args) + self.supported_warn_args(gnu_objc_warning_args))} + def get_option_compile_args(self, options: 'coredata.KeyedOptionDictType') -> T.List[str]: + args = [] + std = options.get_value(self.form_compileropt_key('std')) + if std != 'none': + args.append('-std=' + std) + return args + -class ClangObjCPPCompiler(ClangCompiler, ObjCPPCompiler): +class ClangObjCPPCompiler(ClangCPPStds, ClangCompiler, ObjCPPCompiler): def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool, info: 'MachineInfo', @@ -78,26 +100,14 @@ class ClangObjCPPCompiler(ClangCompiler, ObjCPPCompiler): '3': default_warn_args + ['-Wextra', '-Wpedantic'], 'everything': ['-Weverything']} - def get_options(self) -> coredata.MutableKeyedOptionDictType: - return self.update_options( - super().get_options(), - self.create_option(options.UserComboOption, - OptionKey('cpp_std', machine=self.for_machine), - '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'), - ) - def get_option_compile_args(self, options: 'coredata.KeyedOptionDictType') -> T.List[str]: args = [] - std = options.get_value(OptionKey('cpp_std', machine=self.for_machine)) + std = options.get_value(self.form_compileropt_key('std')) if std != 'none': args.append('-std=' + std) return args -class AppleClangObjCPPCompiler(ClangObjCPPCompiler): +class AppleClangObjCPPCompiler(AppleCPPStdsMixin, ClangObjCPPCompiler): """Handle the differences between Apple's clang and vanilla clang.""" |
