external-project: Setup devenv to run programs

pull/13709/merge
Xavier Claessens 3 weeks ago committed by Xavier Claessens
parent 38dc9894ad
commit 1840bb02ba
  1. 8
      docs/markdown/External-Project-module.md
  2. 7
      docs/markdown/snippets/external_project_devenv.md
  3. 16
      mesonbuild/modules/external_project.py

@ -5,6 +5,8 @@
*This is an experimental module, API could change.*
*Added 0.56.0*
This module allows building code that uses build systems other than
Meson. This module is intended to be used to build Autotools
subprojects as fallback if the dependency couldn't be found on the
@ -47,7 +49,8 @@ Known limitations:
from `-uninstalled.pc` files. This is arguably a bug that could be fixed in
future version of pkg-config/pkgconf.
*Added 0.56.0*
*Since 1.7.0* [Meson devenv][Commands.md#devenv] setup `PATH` and
`LD_LIBRARY_PATH` to be able to run programs.
## Functions
@ -78,7 +81,8 @@ Keyword arguments:
added in case some tags are not found in `configure_options`:
`'--prefix=@PREFIX@'`, `'--libdir=@PREFIX@/@LIBDIR@'`, and
`'--includedir=@PREFIX@/@INCLUDEDIR@'`. It was previously considered a fatal
error to not specify them.
error to not specify them. *Since 1.7.0* `@BINDIR@` and `'--bindir=@PREFIX@/@BINDIR@'`
default argument have been added.
- `cross_configure_options`: Extra options appended to `configure_options` only
when cross compiling. special tag `@HOST@` will be replaced by
`'{}-{}-{}'.format(host_machine.cpu_family(), build_machine.system(), host_machine.system()`.

@ -0,0 +1,7 @@
## Devenv support in external project module
The [external project module](External-Project-module.md) now setups `PATH` and
`LD_LIBRARY_PATH` to be able to run programs.
`@BINDIR@` is now substitued in arguments and `'--bindir=@PREFIX@/@BINDIR@'`
default argument have been added.

@ -81,6 +81,9 @@ class ExternalProject(NewExtensionModule):
_l = self.env.coredata.get_option(OptionKey('libdir'))
assert isinstance(_l, str), 'for mypy'
self.libdir = Path(_l)
_l = self.env.coredata.get_option(OptionKey('bindir'))
assert isinstance(_l, str), 'for mypy'
self.bindir = Path(_l)
_i = self.env.coredata.get_option(OptionKey('includedir'))
assert isinstance(_i, str), 'for mypy'
self.includedir = Path(_i)
@ -118,6 +121,7 @@ class ExternalProject(NewExtensionModule):
d = [('PREFIX', '--prefix=@PREFIX@', self.prefix.as_posix()),
('LIBDIR', '--libdir=@PREFIX@/@LIBDIR@', self.libdir.as_posix()),
('BINDIR', '--bindir=@PREFIX@/@BINDIR@', self.bindir.as_posix()),
('INCLUDEDIR', None, self.includedir.as_posix()),
]
self._validate_configure_options(d, state)
@ -278,6 +282,7 @@ class ExternalProjectModule(ExtensionModule):
def __init__(self, interpreter: 'Interpreter'):
super().__init__(interpreter)
self.devenv: T.Optional[EnvironmentVariables] = None
self.methods.update({'add_project': self.add_project,
})
@ -299,8 +304,19 @@ class ExternalProjectModule(ExtensionModule):
kwargs['env'],
kwargs['verbose'],
kwargs['depends'])
abs_libdir = Path(project.install_dir, project.rel_prefix, project.libdir).as_posix()
abs_bindir = Path(project.install_dir, project.rel_prefix, project.bindir).as_posix()
env = state.environment.get_env_for_paths({abs_libdir}, {abs_bindir})
if self.devenv is None:
self.devenv = env
else:
self.devenv.merge(env)
return ModuleReturnValue(project, project.targets)
def postconf_hook(self, b: build.Build) -> None:
if self.devenv is not None:
b.devenv.append(self.devenv)
def initialize(interp: 'Interpreter') -> ExternalProjectModule:
return ExternalProjectModule(interp)

Loading…
Cancel
Save