Add API for modules that wants to define their devenv

pull/10047/head
Xavier Claessens 3 years ago committed by Xavier Claessens
parent ad75a2bfec
commit c4b8c23eb1
  1. 4
      mesonbuild/modules/__init__.py
  2. 4
      mesonbuild/modules/gnome.py
  3. 9
      mesonbuild/msetup.py

@ -26,6 +26,7 @@ if T.TYPE_CHECKING:
from ..interpreterbase import TYPE_var, TYPE_kwargs
from ..programs import ExternalProgram
from ..wrap import WrapMode
from ..build import EnvironmentVariables
class ModuleState:
"""Object passed to all module methods.
@ -148,6 +149,9 @@ class NewExtensionModule(ModuleObject):
def found() -> bool:
return True
def get_devenv(self) -> T.Optional['EnvironmentVariables']:
return None
# FIXME: Port all modules to stop using self.interpreter and use API on
# ModuleState instead. Modules should stop using this class and instead use
# ModuleObject base class.

@ -752,9 +752,11 @@ class GnomeModule(ExtensionModule):
def _devenv_prepend(self, varname: str, value: str) -> None:
if self.devenv is None:
self.devenv = build.EnvironmentVariables()
self.interpreter.build.devenv.append(self.devenv)
self.devenv.prepend(varname, [value])
def get_devenv(self) -> T.Optional[build.EnvironmentVariables]:
return self.devenv
def _get_gir_dep(self, state: 'ModuleState') -> T.Tuple[Dependency, T.Union[build.Executable, 'ExternalProgram', 'OverrideProgram'],
T.Union[build.Executable, 'ExternalProgram', 'OverrideProgram']]:
if not self.gir_dep:

@ -245,7 +245,7 @@ class MesonApp:
profile.runctx('intr.backend.generate()', globals(), locals(), filename=fname)
else:
intr.backend.generate()
b.devenv.append(intr.backend.get_devenv())
self._finalize_devenv(b, intr)
build.save(b, dumpfile)
if env.first_invocation:
# Use path resolved by coredata because they could have been
@ -288,6 +288,13 @@ class MesonApp:
os.unlink(cdf)
raise
def _finalize_devenv(self, b: build.Build, intr: interpreter.Interpreter) -> None:
b.devenv.append(intr.backend.get_devenv())
for mod in intr.modules.values():
devenv = mod.get_devenv()
if devenv:
b.devenv.append(devenv)
def run(options: argparse.Namespace) -> int:
coredata.parse_cmd_line_options(options)
app = MesonApp(options)

Loading…
Cancel
Save