Move builtin option check into OptionStore.

uniquefilenames
Jussi Pakkanen 5 months ago
parent 472d8852e9
commit 5c6e9d2d8f
  1. 4
      mesonbuild/coredata.py
  2. 2
      mesonbuild/mconf.py
  3. 2
      mesonbuild/mintro.py
  4. 4
      mesonbuild/options.py
  5. 4
      mesonbuild/utils/universal.py

@ -453,7 +453,7 @@ class CoreData:
def set_option(self, key: OptionKey, value, first_invocation: bool = False) -> bool:
dirty = False
if key.is_builtin():
if self.optstore.is_builtin_option(key):
if key.name == 'prefix':
value = self.sanitize_prefix(value)
else:
@ -694,7 +694,7 @@ class CoreData:
# Always test this using the HOST machine, as many builtin options
# are not valid for the BUILD machine, but the yielding value does
# not differ between them even when they are valid for both.
if subproject and k.is_builtin() and self.optstore.get_value_object(k.evolve(subproject='', machine=MachineChoice.HOST)).yielding:
if subproject and self.optstore.is_builtin_option(k) and self.optstore.get_value_object(k.evolve(subproject='', machine=MachineChoice.HOST)).yielding:
continue
# Skip base, compiler, and backend options, they are handled when
# adding languages and setting backend.

@ -277,7 +277,7 @@ class Conf:
if self.build and k.module not in self.build.modules:
continue
module_options[k.module][k] = v
elif k.is_builtin():
elif self.coredata.optstore.is_builtin_option(k):
core_options[k] = v
host_core_options = self.split_options_per_subproject({k: v for k, v in core_options.items() if k.machine is MachineChoice.HOST})

@ -298,7 +298,7 @@ def list_buildoptions(coredata: cdata.CoreData, subprojects: T.Optional[T.List[s
dir_options[k] = v
elif k in test_option_names:
test_options[k] = v
elif k.is_builtin():
elif coredata.optstore.is_builtin_option(k):
core_options[k] = v
if not v.yielding:
for s in subprojects:

@ -545,6 +545,10 @@ class OptionStore:
def is_reserved_name(self, key: OptionKey) -> bool:
return not self.is_project_option(key)
def is_builtin_option(self, key: OptionKey) -> bool:
"""Convenience method to check if this is a builtin option."""
return key.type is OptionType.BUILTIN
def is_base_option(self, key: OptionKey) -> bool:
"""Convenience method to check if this is a base option."""
return key.type is OptionType.BASE

@ -2387,10 +2387,6 @@ class OptionKey:
"""Convenience method for key.evolve(machine=MachineChoice.HOST)."""
return self.evolve(machine=MachineChoice.HOST)
def is_builtin(self) -> bool:
"""Convenience method to check if this is a builtin option."""
return self.type is OptionType.BUILTIN
def is_compiler(self) -> bool:
"""Convenience method to check if this is a builtin option."""
return self.type is OptionType.COMPILER

Loading…
Cancel
Save