diff options
| author | Charles Brunet <charles.brunet@optelgroup.com> | 2024-01-11 15:20:44 -0500 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2024-03-15 09:23:46 -0700 |
| commit | dacb25db101e7ede60b6ba3dd5a7d1935dc5ff73 (patch) | |
| tree | eef37958f0c54683829453d03d4e13bf5e02377f /mesonbuild/compilers/c.py | |
| parent | d08ef2c08bb0120f0ba20dbc10575b7e15577349 (diff) | |
| download | meson-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.py | 39 |
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 |
