diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-10-06 18:35:36 +0200 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-10-06 14:44:31 -0700 |
| commit | e435eaadef39a426c0d010c858370d27769e5097 (patch) | |
| tree | c42913cfc119610f2b158d642647549ba7576f56 /mesonbuild/options.py | |
| parent | 18bac4af9ec124fb3db242bfee23ec1a9134b872 (diff) | |
| download | meson-e435eaadef39a426c0d010c858370d27769e5097.tar.gz | |
options: make is_base_option stricter
Only return True if the option actually exists. While at it, ensure
that the right machine is looked up in get_default_for_b_option; this
allows removing the try/except block.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild/options.py')
| -rw-r--r-- | mesonbuild/options.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/mesonbuild/options.py b/mesonbuild/options.py index dcfa4c3b6..c2026827d 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -1152,10 +1152,7 @@ class OptionStore: def get_default_for_b_option(self, key: OptionKey) -> ElementaryOptionValues: assert self.is_base_option(key) - try: - return COMPILER_BASE_OPTIONS[key.evolve(subproject=None)].default - except KeyError: - raise MesonBugException(f'Requested base option {key} which does not exist.') + return COMPILER_BASE_OPTIONS[key.evolve(subproject=None, machine=MachineChoice.HOST)].default def remove(self, key: OptionKey) -> None: del self.options[key] @@ -1210,7 +1207,8 @@ class OptionStore: def is_base_option(self, key: OptionKey) -> bool: """Convenience method to check if this is a base option.""" - return key.name.startswith('b_') + # The "startswith" check is just an optimization + return key.name.startswith('b_') and key.evolve(subproject=None, machine=MachineChoice.HOST) in COMPILER_BASE_OPTIONS def is_backend_option(self, key: OptionKey) -> bool: """Convenience method to check if this is a backend option.""" @@ -1322,8 +1320,7 @@ class OptionStore: return True if first_invocation and self.is_backend_option(key): return True - return (self.is_base_option(key) and - key.evolve(subproject=None, machine=MachineChoice.HOST) in COMPILER_BASE_OPTIONS) + return self.is_base_option(key) def validate_cmd_line_options(self, cmd_line_options: OptionDict) -> None: unknown_options = [] |
