build: store Build.modules as a set

Since it's only used to check membership, a set makes more sense. Also
add some documentation to the attribute
pull/13908/head
Dylan Baker 10 months ago
parent 67ea6d4e79
commit f1a09aabf1
  1. 6
      mesonbuild/build.py
  2. 4
      mesonbuild/interpreter/interpreter.py

@ -275,7 +275,11 @@ class Build:
self.dependency_overrides: PerMachine[T.Dict[T.Tuple, DependencyOverride]] = PerMachineDefaultable.default(
environment.is_cross_build(), {}, {})
self.devenv: T.List[EnvironmentVariables] = []
self.modules: T.List[str] = []
self.modules: T.Set[str] = set()
"""Used to track which modules are enabled in all subprojects.
Needed for tracking whether a modules options needs to be exposed to the user.
"""
def get_build_targets(self):
build_targets = OrderedDict()

@ -632,8 +632,8 @@ class Interpreter(InterpreterBase, HoldableObject):
ext_module = NotFoundExtensionModule(real_modname)
else:
ext_module = module.initialize(self)
assert isinstance(ext_module, (ExtensionModule, NewExtensionModule)), 'for mypy'
self.build.modules.append(real_modname)
assert isinstance(ext_module, (ExtensionModule, NewExtensionModule))
self.build.modules.add(real_modname)
if ext_module.INFO.added:
FeatureNew.single_use(f'module {ext_module.INFO.name}', ext_module.INFO.added, self.subproject, location=node)
if ext_module.INFO.deprecated:

Loading…
Cancel
Save