From 0c36ace4b783f17dd7c60eefd7aca8b4556c519a Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sat, 29 Jun 2024 18:14:00 +0300 Subject: [PATCH] Move base option check into OptionStore. --- mesonbuild/mconf.py | 2 +- mesonbuild/mintro.py | 2 +- mesonbuild/options.py | 4 ++++ mesonbuild/utils/universal.py | 4 ---- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index 1294479d6..dd11e2ddb 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -292,7 +292,7 @@ class Conf: 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('Base options', {k: v for k, v in self.coredata.optstore.items() if k.is_base()}) + 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: self.print_options('', build_compiler_options.get('', {})) diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 17d1b08fb..a49c6e137 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -329,7 +329,7 @@ def list_buildoptions(coredata: cdata.CoreData, subprojects: T.Optional[T.List[s 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 k.is_base()}, 'base') + 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()}, 'compiler', diff --git a/mesonbuild/options.py b/mesonbuild/options.py index e88710d08..87f82ba63 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -544,3 +544,7 @@ class OptionStore: def is_reserved_name(self, key: OptionKey) -> bool: return not self.is_project_option(key) + + def is_base_option(self, key: OptionKey) -> bool: + """Convenience method to check if this is a base option.""" + return key.type is OptionType.BASE diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index 080f2a76d..31f67693a 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -2403,10 +2403,6 @@ class OptionKey: """This method will be removed once we can delete OptionsView.""" return self.type is OptionType.PROJECT - def is_base(self) -> bool: - """Convenience method to check if this is a base option.""" - return self.type is OptionType.BASE - def pickle_load(filename: str, object_name: str, object_type: T.Type[_PL], suggest_reconfigure: bool = True) -> _PL: load_fail_msg = f'{object_name} file {filename!r} is corrupted.'