summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/cpp.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2024-08-29 15:47:20 -0700
committerJussi Pakkanen <jpakkane@gmail.com>2025-02-05 17:45:38 +0200
commitba3460eb11bbceaf4fef7352bf286cf27184c99a (patch)
treeef001dc11ac342d82296a7e41560dac04f8b89ce /mesonbuild/compilers/cpp.py
parent0e11b90d6f2f9c3e18cb8ff84b1622640666e826 (diff)
downloadmeson-ba3460eb11bbceaf4fef7352bf286cf27184c99a.tar.gz
options: Add an EnumeratedUserOption class
This will allow us to take choices out of the UserOption class, which doesn't actually use this attribute.
Diffstat (limited to 'mesonbuild/compilers/cpp.py')
-rw-r--r--mesonbuild/compilers/cpp.py28
1 files changed, 12 insertions, 16 deletions
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index 7fa9aa833..80f84b38e 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -243,7 +243,7 @@ class ClangCPPCompiler(_StdCPPLibMixin, ClangCPPStds, ClangCompiler, CPPCompiler
self.make_option_name(key),
'C++ exception handling type.',
'default',
- ['none', 'default', 'a', 's', 'sc'])
+ choices=['none', 'default', 'a', 's', 'sc'])
key = self.form_compileropt_key('rtti')
opts[key] = options.UserBooleanOption(
@@ -259,7 +259,7 @@ class ClangCPPCompiler(_StdCPPLibMixin, ClangCPPStds, ClangCompiler, CPPCompiler
if self.info.is_windows() or self.info.is_cygwin():
key = self.form_compileropt_key('winlibs')
- opts[key] = options.UserArrayOption(
+ opts[key] = options.UserStringArrayOption(
self.make_option_name(key),
'Standard Win libraries to link against',
gnu_winlibs)
@@ -399,7 +399,7 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler):
self.make_option_name(key),
'C++ exception handling type.',
'default',
- ['none', 'default', 'a', 's', 'sc'])
+ choices=['none', 'default', 'a', 's', 'sc'])
key = self.form_compileropt_key('std')
std_opt = opts[key]
@@ -449,7 +449,7 @@ class GnuCPPCompiler(_StdCPPLibMixin, GnuCPPStds, GnuCompiler, CPPCompiler):
self.make_option_name(key),
'C++ exception handling type.',
'default',
- ['none', 'default', 'a', 's', 'sc'])
+ choices=['none', 'default', 'a', 's', 'sc'])
key = self.form_compileropt_key('rtti')
opts[key] = options.UserBooleanOption(
@@ -465,7 +465,7 @@ class GnuCPPCompiler(_StdCPPLibMixin, GnuCPPStds, GnuCompiler, CPPCompiler):
if self.info.is_windows() or self.info.is_cygwin():
key = key.evolve(name='cpp_winlibs')
- opts[key] = options.UserArrayOption(
+ opts[key] = options.UserStringArrayOption(
self.make_option_name(key),
'Standard Win libraries to link against',
gnu_winlibs)
@@ -578,7 +578,7 @@ class ElbrusCPPCompiler(ElbrusCompiler, CPPCompiler):
self.make_option_name(key),
'C++ exception handling type.',
'default',
- ['none', 'default', 'a', 's', 'sc'])
+ choices=['none', 'default', 'a', 's', 'sc'])
key = self.form_compileropt_key('debugstl')
opts[key] = options.UserBooleanOption(
@@ -661,7 +661,7 @@ class IntelCPPCompiler(IntelGnuLikeCompiler, CPPCompiler):
self.make_option_name(key),
'C++ exception handling type.',
'default',
- ['none', 'default', 'a', 's', 'sc'])
+ choices=['none', 'default', 'a', 's', 'sc'])
key = self.form_compileropt_key('rtti')
opts[key] = options.UserBooleanOption(
@@ -691,9 +691,7 @@ class IntelCPPCompiler(IntelGnuLikeCompiler, CPPCompiler):
c_stds += ['c++2a']
g_stds += ['gnu++2a']
- std_opt = opts[self.form_compileropt_key('std')]
- assert isinstance(std_opt, options.UserStdOption), 'for mypy'
- std_opt.set_versions(c_stds + g_stds)
+ self._update_language_stds(opts, c_stds + g_stds)
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
@@ -754,7 +752,7 @@ class VisualStudioLikeCPPCompilerMixin(CompilerMixinBase):
self.make_option_name(key),
'C++ exception handling type.',
'default',
- ['none', 'default', 'a', 's', 'sc'])
+ choices=['none', 'default', 'a', 's', 'sc'])
key = self.form_compileropt_key('rtti')
opts[key] = options.UserBooleanOption(
@@ -763,7 +761,7 @@ class VisualStudioLikeCPPCompilerMixin(CompilerMixinBase):
True)
key = self.form_compileropt_key('winlibs')
- opts[key] = options.UserArrayOption(
+ opts[key] = options.UserStringArrayOption(
self.make_option_name(key),
'Standard Win libraries to link against',
msvc_winlibs)
@@ -1040,8 +1038,7 @@ class MetrowerksCPPCompilerARM(MetrowerksCompiler, CPPCompiler):
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = super().get_options()
- key = self.form_compileropt_key('std')
- opts[key].choices = ['none']
+ self._update_language_stds(opts, [])
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
@@ -1069,8 +1066,7 @@ class MetrowerksCPPCompilerEmbeddedPowerPC(MetrowerksCompiler, CPPCompiler):
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = super().get_options()
- key = self.form_compileropt_key('std')
- opts[key].choices = ['none']
+ self._update_language_stds(opts, [])
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: