update the devenv module hooks to support generic modifications to Build

We may want to do things like update install scripts as well, which have
to happen before generating the backend. Instead of adding one module
method per thing to do, use a single function that allows for modifying
the Build object directly.
pull/11530/head
Eli Schwartz 2 years ago
parent 6823cabb83
commit 4a2530802c
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 6
      mesonbuild/modules/__init__.py
  2. 5
      mesonbuild/modules/gnome.py
  3. 9
      mesonbuild/msetup.py

@ -31,7 +31,7 @@ if T.TYPE_CHECKING:
from ..interpreterbase import TYPE_var, TYPE_kwargs from ..interpreterbase import TYPE_var, TYPE_kwargs
from ..programs import OverrideProgram from ..programs import OverrideProgram
from ..wrap import WrapMode from ..wrap import WrapMode
from ..build import EnvironmentVariables, Executable from ..build import Executable
from ..dependencies import Dependency from ..dependencies import Dependency
class ModuleState: class ModuleState:
@ -219,8 +219,8 @@ class NewExtensionModule(ModuleObject):
def found() -> bool: def found() -> bool:
return True return True
def get_devenv(self) -> T.Optional['EnvironmentVariables']: def postconf_hook(self, b: build.Build) -> None:
return None pass
# FIXME: Port all modules to stop using self.interpreter and use API on # FIXME: Port all modules to stop using self.interpreter and use API on
# ModuleState instead. Modules should stop using this class and instead use # ModuleState instead. Modules should stop using this class and instead use

@ -784,8 +784,9 @@ class GnomeModule(ExtensionModule):
self.devenv = build.EnvironmentVariables() self.devenv = build.EnvironmentVariables()
self.devenv.prepend(varname, [value]) self.devenv.prepend(varname, [value])
def get_devenv(self) -> T.Optional[build.EnvironmentVariables]: def postconf_hook(self, b: build.Build) -> None:
return self.devenv if self.devenv is not None:
b.devenv.append(self.devenv)
def _get_gir_dep(self, state: 'ModuleState') -> T.Tuple[Dependency, T.Union[build.Executable, 'ExternalProgram', 'OverrideProgram'], def _get_gir_dep(self, state: 'ModuleState') -> T.Tuple[Dependency, T.Union[build.Executable, 'ExternalProgram', 'OverrideProgram'],
T.Union[build.Executable, 'ExternalProgram', 'OverrideProgram']]: T.Union[build.Executable, 'ExternalProgram', 'OverrideProgram']]:

@ -251,13 +251,14 @@ class MesonApp:
# sync with the time that gets applied to any files. Thus, we dump this file as late as # sync with the time that gets applied to any files. Thus, we dump this file as late as
# possible, but before build files, and if any error occurs, delete it. # possible, but before build files, and if any error occurs, delete it.
cdf = env.dump_coredata() cdf = env.dump_coredata()
self.finalize_postconf_hooks(b, intr)
if self.options.profile: if self.options.profile:
fname = f'profile-{intr.backend.name}-backend.log' fname = f'profile-{intr.backend.name}-backend.log'
fname = os.path.join(self.build_dir, 'meson-private', fname) fname = os.path.join(self.build_dir, 'meson-private', fname)
profile.runctx('intr.backend.generate()', globals(), locals(), filename=fname) profile.runctx('intr.backend.generate()', globals(), locals(), filename=fname)
else: else:
intr.backend.generate() intr.backend.generate()
self._finalize_devenv(b, intr)
build.save(b, dumpfile) build.save(b, dumpfile)
if env.first_invocation: if env.first_invocation:
# Use path resolved by coredata because they could have been # Use path resolved by coredata because they could have been
@ -300,13 +301,11 @@ class MesonApp:
os.unlink(cdf) os.unlink(cdf)
raise raise
def _finalize_devenv(self, b: build.Build, intr: interpreter.Interpreter) -> None: def finalize_postconf_hooks(self, b: build.Build, intr: interpreter.Interpreter) -> None:
b.devenv.append(intr.backend.get_devenv()) b.devenv.append(intr.backend.get_devenv())
b.devenv.append(PkgConfigDependency.get_env(intr.environment, MachineChoice.HOST, uninstalled=True)) b.devenv.append(PkgConfigDependency.get_env(intr.environment, MachineChoice.HOST, uninstalled=True))
for mod in intr.modules.values(): for mod in intr.modules.values():
devenv = mod.get_devenv() mod.postconf_hook(b)
if devenv:
b.devenv.append(devenv)
def run(options: T.Union[argparse.Namespace, T.List[str]]) -> int: def run(options: T.Union[argparse.Namespace, T.List[str]]) -> int:
if not isinstance(options, argparse.Namespace): if not isinstance(options, argparse.Namespace):

Loading…
Cancel
Save