From 472d8852e9d9b21d0a20f52d37915127e556e8d9 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sat, 29 Jun 2024 18:29:52 +0300 Subject: [PATCH] Move backend option check into OptionStore. --- mesonbuild/ast/introspection.py | 2 +- mesonbuild/interpreter/interpreter.py | 2 +- mesonbuild/mconf.py | 2 +- mesonbuild/mintro.py | 2 +- mesonbuild/options.py | 4 ++++ mesonbuild/utils/universal.py | 4 ---- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py index 07f82dfe6..412070dcd 100644 --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -130,7 +130,7 @@ class IntrospectionInterpreter(AstInterpreter): self.do_subproject(SubProject(i)) self.coredata.init_backend_options(self.backend) - options = {k: v for k, v in self.environment.options.items() if k.is_backend()} + options = {k: v for k, v in self.environment.options.items() if self.environment.coredata.optstore.is_backend_option(k)} self.coredata.set_options(options) self._add_languages(proj_langs, True, MachineChoice.HOST) diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 742d24c89..aac63b157 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -1148,7 +1148,7 @@ class Interpreter(InterpreterBase, HoldableObject): if self.environment.first_invocation: self.coredata.init_backend_options(backend_name) - options = {k: v for k, v in self.environment.options.items() if k.is_backend()} + options = {k: v for k, v in self.environment.options.items() if self.environment.coredata.optstore.is_backend_option(k)} self.coredata.set_options(options) @typed_pos_args('project', str, varargs=str) diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index dd11e2ddb..0f345d96a 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -291,7 +291,7 @@ class Conf: self.print_options('Core options', host_core_options['']) if show_build_options: self.print_options('', build_core_options['']) - self.print_options('Backend options', {k: v for k, v in self.coredata.optstore.items() if k.is_backend()}) + self.print_options('Backend options', {k: v for k, v in self.coredata.optstore.items() if self.coredata.optstore.is_backend_option(k)}) self.print_options('Base options', {k: v for k, v in self.coredata.optstore.items() if self.coredata.optstore.is_base_option(k)}) self.print_options('Compiler options', host_compiler_options.get('', {})) if show_build_options: diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index a49c6e137..da1afdbd5 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -328,7 +328,7 @@ def list_buildoptions(coredata: cdata.CoreData, subprojects: T.Optional[T.List[s optlist.append(optdict) add_keys(core_options, 'core') - add_keys({k: v for k, v in coredata.optstore.items() if k.is_backend()}, 'backend') + add_keys({k: v for k, v in coredata.optstore.items() if coredata.optstore.is_backend_option(k)}, 'backend') add_keys({k: v for k, v in coredata.optstore.items() if coredata.optstore.is_base_option(k)}, 'base') add_keys( {k: v for k, v in sorted(coredata.optstore.items(), key=lambda i: i[0].machine) if k.is_compiler()}, diff --git a/mesonbuild/options.py b/mesonbuild/options.py index 87f82ba63..4af9c97ac 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -548,3 +548,7 @@ class OptionStore: def is_base_option(self, key: OptionKey) -> bool: """Convenience method to check if this is a base option.""" return key.type is OptionType.BASE + + def is_backend_option(self, key: OptionKey) -> bool: + """Convenience method to check if this is a backend option.""" + return key.type is OptionType.BACKEND diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index 31f67693a..97cc0dc3a 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -2387,10 +2387,6 @@ class OptionKey: """Convenience method for key.evolve(machine=MachineChoice.HOST).""" return self.evolve(machine=MachineChoice.HOST) - def is_backend(self) -> bool: - """Convenience method to check if this is a backend option.""" - return self.type is OptionType.BACKEND - def is_builtin(self) -> bool: """Convenience method to check if this is a builtin option.""" return self.type is OptionType.BUILTIN