diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2021-05-08 00:23:11 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-05-11 22:47:17 +0300 |
commit | c54dd63547b030e3d9feee694ec6f49c434f0df8 (patch) | |
tree | f759bd9c8ab64a0cdda5918ebc3a832e017027e4 /mesonbuild | |
parent | 8f12102549348f3dd24d72633f3f8f82258e8a0a (diff) | |
download | meson-c54dd63547b030e3d9feee694ec6f49c434f0df8.zip meson-c54dd63547b030e3d9feee694ec6f49c434f0df8.tar.gz meson-c54dd63547b030e3d9feee694ec6f49c434f0df8.tar.bz2 |
Make objective C use C standard version. Closes #5495.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/compilers/objc.py | 20 | ||||
-rw-r--r-- | mesonbuild/compilers/objcpp.py | 21 |
2 files changed, 39 insertions, 2 deletions
diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py index 32f17ff..ec8d290 100644 --- a/mesonbuild/compilers/objc.py +++ b/mesonbuild/compilers/objc.py @@ -14,7 +14,8 @@ import typing as T -from ..mesonlib import MachineChoice +from .. import coredata +from ..mesonlib import MachineChoice, OptionKey from .compilers import Compiler from .mixins.clike import CLikeCompiler @@ -84,6 +85,23 @@ class ClangObjCCompiler(ClangCompiler, ObjCCompiler): '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-Wpedantic']} + def get_options(self) -> 'coredata.KeyedOptionDictType': + opts = super().get_options() + opts.update({ + OptionKey('std', machine=self.for_machine, lang='c'): coredata.UserComboOption( + 'C language standard to use', + ['none', 'c89', 'c99', 'c11', 'c17'], + '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='c')] + if std.value != 'none': + args.append('-std=' + std.value) + return args class AppleClangObjCCompiler(ClangObjCCompiler): diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py index 003da54..ad909f1 100644 --- a/mesonbuild/compilers/objcpp.py +++ b/mesonbuild/compilers/objcpp.py @@ -14,7 +14,8 @@ import typing as T -from ..mesonlib import MachineChoice +from .. import coredata +from ..mesonlib import MachineChoice, OptionKey from .mixins.clike import CLikeCompiler from .compilers import Compiler @@ -85,6 +86,24 @@ class ClangObjCPPCompiler(ClangCompiler, ObjCPPCompiler): '3': default_warn_args + ['-Wextra', '-Wpedantic']} + def get_options(self) -> 'coredata.KeyedOptionDictType': + 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'], + '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): |