From c2552527fb2f607052c7aed633b67dbb19f06e38 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sat, 29 Jun 2024 18:50:31 +0300 Subject: [PATCH] Move compiler option check into OptionStore. --- mesonbuild/mconf.py | 4 ++-- mesonbuild/mintro.py | 2 +- mesonbuild/options.py | 4 ++++ mesonbuild/utils/universal.py | 4 ---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index 0d73b5be2..0a88e57ed 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -282,8 +282,8 @@ class Conf: host_core_options = self.split_options_per_subproject({k: v for k, v in core_options.items() if k.machine is MachineChoice.HOST}) build_core_options = self.split_options_per_subproject({k: v for k, v in core_options.items() if k.machine is MachineChoice.BUILD}) - host_compiler_options = self.split_options_per_subproject({k: v for k, v in self.coredata.optstore.items() if k.is_compiler() and k.machine is MachineChoice.HOST}) - build_compiler_options = self.split_options_per_subproject({k: v for k, v in self.coredata.optstore.items() if k.is_compiler() and k.machine is MachineChoice.BUILD}) + host_compiler_options = self.split_options_per_subproject({k: v for k, v in self.coredata.optstore.items() if self.coredata.optstore.is_compiler_option(k) and k.machine is MachineChoice.HOST}) + build_compiler_options = self.split_options_per_subproject({k: v for k, v in self.coredata.optstore.items() if self.coredata.optstore.is_compiler_option(k) and k.machine is MachineChoice.BUILD}) project_options = self.split_options_per_subproject({k: v for k, v in self.coredata.optstore.items() if self.coredata.optstore.is_project_option(k)}) show_build_options = self.default_values_only or self.build.environment.is_cross_build() diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 7fecfd01f..718bfb029 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -331,7 +331,7 @@ def list_buildoptions(coredata: cdata.CoreData, subprojects: T.Optional[T.List[s 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()}, + {k: v for k, v in sorted(coredata.optstore.items(), key=lambda i: i[0].machine) if coredata.optstore.is_compiler_option(k)}, 'compiler', ) add_keys(dir_options, 'directory') diff --git a/mesonbuild/options.py b/mesonbuild/options.py index 4b9e61f43..631868628 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -556,3 +556,7 @@ class OptionStore: def is_backend_option(self, key: OptionKey) -> bool: """Convenience method to check if this is a backend option.""" return key.type is OptionType.BACKEND + + def is_compiler_option(self, key: OptionKey) -> bool: + """Convenience method to check if this is a compiler option.""" + return key.type is OptionType.COMPILER diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index 5f533f237..4db209a73 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_compiler(self) -> bool: - """Convenience method to check if this is a builtin option.""" - return self.type is OptionType.COMPILER - def is_project_hack_for_optionsview(self) -> bool: """This method will be removed once we can delete OptionsView.""" return self.type is OptionType.PROJECT