summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/objc.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/compilers/objc.py')
-rw-r--r--mesonbuild/compilers/objc.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py
index 97550c2ea..de23e70cf 100644
--- a/mesonbuild/compilers/objc.py
+++ b/mesonbuild/compilers/objc.py
@@ -5,13 +5,13 @@ from __future__ import annotations
import typing as T
-from .. import options
-from ..options import OptionKey
+from ..options import OptionKey, UserStdOption
+from .c import ALL_STDS
from .compilers import Compiler
+from .mixins.clang import ClangCompiler, ClangCStds
from .mixins.clike import CLikeCompiler
from .mixins.gnu import GnuCompiler, gnu_common_warning_args, gnu_objc_warning_args
-from .mixins.clang import ClangCompiler
if T.TYPE_CHECKING:
from .. import coredata
@@ -34,6 +34,14 @@ class ObjCCompiler(CLikeCompiler, Compiler):
linker=linker)
CLikeCompiler.__init__(self)
+ def get_options(self) -> coredata.MutableKeyedOptionDictType:
+ opts = super().get_options()
+ key = self.form_compileropt_key('std')
+ opts.update({
+ key: UserStdOption('c', ALL_STDS),
+ })
+ return opts
+
@staticmethod
def get_display_language() -> str:
return 'Objective-C'
@@ -42,6 +50,11 @@ class ObjCCompiler(CLikeCompiler, Compiler):
code = '#import<stddef.h>\nint main(void) { return 0; }\n'
return self._sanity_check_impl(work_dir, environment, 'sanitycheckobjc.m', code)
+ def form_compileropt_key(self, basename: str) -> OptionKey:
+ if basename == 'std':
+ return OptionKey(f'c_{basename}', machine=self.for_machine)
+ return super().form_compileropt_key(basename)
+
class GnuObjCCompiler(GnuCompiler, ObjCCompiler):
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,
@@ -62,7 +75,7 @@ class GnuObjCCompiler(GnuCompiler, ObjCCompiler):
self.supported_warn_args(gnu_objc_warning_args))}
-class ClangObjCCompiler(ClangCompiler, ObjCCompiler):
+class ClangObjCCompiler(ClangCStds, ClangCompiler, ObjCCompiler):
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,
@@ -78,19 +91,9 @@ class ClangObjCCompiler(ClangCompiler, ObjCCompiler):
'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('c_std', machine=self.for_machine),
- 'C language standard to use',
- ['none', 'c89', 'c99', 'c11', 'c17', 'gnu89', 'gnu99', 'gnu11', 'gnu17'],
- 'none'),
- )
-
def get_option_compile_args(self, options: 'coredata.KeyedOptionDictType') -> T.List[str]:
args = []
- std = options.get_value(OptionKey('c_std', machine=self.for_machine))
+ std = options.get_value(self.form_compileropt_key('std'))
if std != 'none':
args.append('-std=' + std)
return args
@@ -98,3 +101,7 @@ class ClangObjCCompiler(ClangCompiler, ObjCCompiler):
class AppleClangObjCCompiler(ClangObjCCompiler):
"""Handle the differences between Apple's clang and vanilla clang."""
+
+ _C17_VERSION = '>=10.0.0'
+ _C18_VERSION = '>=11.0.0'
+ _C2X_VERSION = '>=11.0.0'