aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/cpp.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-10-13 10:09:38 -0700
committerDylan Baker <dylan@pnwbakers.com>2020-11-12 10:03:15 -0800
commit2844afedde3992564e0de4538b29781a420f8576 (patch)
treedc49820b752efede769477e81dac18023fd4928c /mesonbuild/compilers/cpp.py
parenta28a34c6845144d2e947bd698244fb33909b4d45 (diff)
downloadmeson-2844afedde3992564e0de4538b29781a420f8576.zip
meson-2844afedde3992564e0de4538b29781a420f8576.tar.gz
meson-2844afedde3992564e0de4538b29781a420f8576.tar.bz2
compilers: define standards in the base language compiler
And then update the choices in each leaf class. This way we don't end up with another case where we implicitly allow an invalid standard to be set on a compiler that doesn't have a 'std' setting currently.
Diffstat (limited to 'mesonbuild/compilers/cpp.py')
-rw-r--r--mesonbuild/compilers/cpp.py74
1 files changed, 29 insertions, 45 deletions
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index afc812a..6ba87eb 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -167,6 +167,17 @@ class CPPCompiler(CLikeCompiler, Compiler):
raise MesonException('C++ Compiler does not support -std={}'.format(cpp_std))
+ def get_options(self) -> 'OptionDictType':
+ opts = super().get_options()
+ opts.update({
+ 'std': coredata.UserComboOption(
+ 'C++ language standard to use',
+ ['none'],
+ 'none',
+ ),
+ })
+ return opts
+
class ClangCPPCompiler(ClangCompiler, CPPCompiler):
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
@@ -192,13 +203,11 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler):
'default',
),
'rtti': coredata.UserBooleanOption('Enable RTTI', True),
- 'std': coredata.UserComboOption(
- 'C++ language standard to use',
- ['none', 'c++98', 'c++03', 'c++11', 'c++14', 'c++17', 'c++1z', 'c++2a',
- 'gnu++11', 'gnu++14', 'gnu++17', 'gnu++1z', 'gnu++2a'],
- 'none',
- ),
})
+ opts['std'].choices = [ # type: ignore
+ 'none', 'c++98', 'c++03', 'c++11', 'c++14', 'c++17', 'c++1z',
+ 'c++2a', 'gnu++11', 'gnu++14', 'gnu++17', 'gnu++1z', 'gnu++2a',
+ ]
if self.info.is_windows() or self.info.is_cygwin():
opts.update({
'winlibs': coredata.UserArrayOption(
@@ -283,15 +292,11 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler):
['none', 'default', 'a', 's', 'sc'],
'default',
),
- 'std': coredata.UserComboOption(
- 'C++ language standard to use',
- [
- 'none', 'c++98', 'c++03', 'c++11', 'c++14', 'c++17',
- 'gnu++98', 'gnu++03', 'gnu++11', 'gnu++14', 'gnu++17',
- ],
- 'none',
- ),
})
+ opts['std'].choices = [ # type: ignore
+ 'none', 'c++98', 'c++03', 'c++11', 'c++14', 'c++17', 'gnu++98',
+ 'gnu++03', 'gnu++11', 'gnu++14', 'gnu++17',
+ ]
return opts
def get_option_compile_args(self, options: 'OptionDictType') -> T.List[str]:
@@ -332,17 +337,16 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler):
'default',
),
'rtti': coredata.UserBooleanOption('Enable RTTI', True),
- 'std': coredata.UserComboOption(
- 'C++ language standard to use',
- ['none', 'c++98', 'c++03', 'c++11', 'c++14', 'c++17', 'c++1z', 'c++2a',
- 'gnu++03', 'gnu++11', 'gnu++14', 'gnu++17', 'gnu++1z', 'gnu++2a'],
- 'none',
- ),
'debugstl': coredata.UserBooleanOption(
'STL debug mode',
False,
)
})
+ opts['std'].choices = [ # type: ignore
+ 'none', 'c++98', 'c++03', 'c++11', 'c++14', 'c++17', 'c++1z',
+ 'c++2a', 'gnu++03', 'gnu++11', 'gnu++14', 'gnu++17', 'gnu++1z',
+ 'gnu++2a',
+ ]
if self.info.is_windows() or self.info.is_cygwin():
opts.update({
'winlibs': coredata.UserArrayOption(
@@ -437,16 +441,12 @@ class ElbrusCPPCompiler(GnuCPPCompiler, ElbrusCompiler):
['none', 'default', 'a', 's', 'sc'],
'default',
),
- 'std': coredata.UserComboOption(
- 'C++ language standard to use',
- cpp_stds,
- 'none',
- ),
'debugstl': coredata.UserBooleanOption(
'STL debug mode',
False,
),
})
+ opts['std'].choices = cpp_stds # type: ignore
return opts
# Elbrus C++ compiler does not have lchmod, but there is only linker warning, not compiler error.
@@ -515,13 +515,9 @@ class IntelCPPCompiler(IntelGnuLikeCompiler, CPPCompiler):
'default',
),
'rtti': coredata.UserBooleanOption('Enable RTTI', True),
- 'std': coredata.UserComboOption(
- 'C++ language standard to use',
- ['none'] + c_stds + g_stds,
- 'none',
- ),
'debugstl': coredata.UserBooleanOption('STL debug mode', False),
})
+ opts['std'].choices = ['none'] + c_stds + g_stds # type: ignore
return opts
def get_option_compile_args(self, options: 'OptionDictType') -> T.List[str]:
@@ -573,16 +569,12 @@ class VisualStudioLikeCPPCompilerMixin(CompilerMixinBase):
'default',
),
'rtti': coredata.UserBooleanOption('Enable RTTI', True),
- 'std': coredata.UserComboOption(
- 'C++ language standard to use',
- cpp_stds,
- 'none',
- ),
'winlibs': coredata.UserArrayOption(
'Windows libs to link against.',
msvc_winlibs,
),
})
+ opts['std'].choices = cpp_stds # type: ignore
return opts
def get_option_compile_args(self, options: 'OptionDictType') -> T.List[str]:
@@ -726,13 +718,7 @@ class ArmCPPCompiler(ArmCompiler, CPPCompiler):
def get_options(self) -> 'OptionDictType':
opts = CPPCompiler.get_options(self)
- opts.update({
- 'std': coredata.UserComboOption(
- 'C++ language standard to use',
- ['none', 'c++03', 'c++11'],
- 'none',
- ),
- })
+ opts['std'].choices = ['none', 'c++03', 'c++11'] # type: ignore
return opts
def get_option_compile_args(self, options: 'OptionDictType') -> T.List[str]:
@@ -790,9 +776,7 @@ class C2000CPPCompiler(C2000Compiler, CPPCompiler):
def get_options(self) -> 'OptionDictType':
opts = CPPCompiler.get_options(self)
- opts.update({'std': coredata.UserComboOption('C++ language standard to use',
- ['none', 'c++03'],
- 'none')})
+ opts['std'].choices = ['none', 'c++03'] # type: ignore
return opts
def get_always_args(self) -> T.List[str]: