summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/c.py
diff options
context:
space:
mode:
authorCharles Brunet <charles.brunet@optelgroup.com>2024-01-11 15:20:44 -0500
committerDylan Baker <dylan@pnwbakers.com>2024-03-15 09:23:46 -0700
commitdacb25db101e7ede60b6ba3dd5a7d1935dc5ff73 (patch)
treeeef37958f0c54683829453d03d4e13bf5e02377f /mesonbuild/compilers/c.py
parentd08ef2c08bb0120f0ba20dbc10575b7e15577349 (diff)
downloadmeson-dacb25db101e7ede60b6ba3dd5a7d1935dc5ff73.tar.gz
Improve error messages for invalid option values
By adding the option name to UserOption object, it is now possible to display the name of the affected option when the given option value is not valid. Fixes #12635
Diffstat (limited to 'mesonbuild/compilers/c.py')
-rw-r--r--mesonbuild/compilers/c.py39
1 files changed, 21 insertions, 18 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 048649a32..7e2146111 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -152,12 +152,13 @@ class ClangCCompiler(_ClangCStds, ClangCompiler, CCompiler):
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = super().get_options()
if self.info.is_windows() or self.info.is_cygwin():
- opts.update({
- OptionKey('winlibs', machine=self.for_machine, lang=self.language): coredata.UserArrayOption(
- 'Standard Win libraries to link against',
- gnu_winlibs,
- ),
- })
+ self.update_options(
+ opts,
+ self.create_option(coredata.UserArrayOption,
+ OptionKey('winlibs', machine=self.for_machine, lang=self.language),
+ 'Standard Win libraries to link against',
+ gnu_winlibs),
+ )
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
@@ -290,12 +291,13 @@ class GnuCCompiler(GnuCompiler, CCompiler):
assert isinstance(std_opt, coredata.UserStdOption), 'for mypy'
std_opt.set_versions(stds, gnu=True)
if self.info.is_windows() or self.info.is_cygwin():
- opts.update({
- key.evolve('winlibs'): coredata.UserArrayOption(
- 'Standard Win libraries to link against',
- gnu_winlibs,
- ),
- })
+ self.update_options(
+ opts,
+ self.create_option(coredata.UserArrayOption,
+ key.evolve('winlibs'),
+ 'Standard Win libraries to link against',
+ gnu_winlibs),
+ )
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
@@ -425,15 +427,16 @@ class VisualStudioLikeCCompilerMixin(CompilerMixinBase):
"""Shared methods that apply to MSVC-like C compilers."""
- def get_options(self) -> 'MutableKeyedOptionDictType':
- opts = super().get_options()
- opts.update({
- OptionKey('winlibs', machine=self.for_machine, lang=self.language): coredata.UserArrayOption(
+ def get_options(self) -> MutableKeyedOptionDictType:
+ return self.update_options(
+ super().get_options(),
+ self.create_option(
+ coredata.UserArrayOption,
+ OptionKey('winlibs', machine=self.for_machine, lang=self.language),
'Windows libs to link against.',
msvc_winlibs,
),
- })
- return opts
+ )
def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
# need a TypeDict to make this work