summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xclaessens@netflix.com>2024-10-26 17:49:10 -0400
committerXavier Claessens <xclaesse@gmail.com>2024-10-28 09:03:46 -0400
commit1840bb02ba741fb62a8d613a71431a8d7fa86a00 (patch)
treeda37ddffecea5d3e74afc2ca132a7d3b77399611
parent38dc9894add23691a948a8a733d3175e0b94b183 (diff)
downloadmeson-1840bb02ba741fb62a8d613a71431a8d7fa86a00.tar.gz
external-project: Setup devenv to run programs
-rw-r--r--docs/markdown/External-Project-module.md8
-rw-r--r--docs/markdown/snippets/external_project_devenv.md7
-rw-r--r--mesonbuild/modules/external_project.py16
3 files changed, 29 insertions, 2 deletions
diff --git a/docs/markdown/External-Project-module.md b/docs/markdown/External-Project-module.md
index 615c6c117..39449fe21 100644
--- a/docs/markdown/External-Project-module.md
+++ b/docs/markdown/External-Project-module.md
@@ -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()`.
diff --git a/docs/markdown/snippets/external_project_devenv.md b/docs/markdown/snippets/external_project_devenv.md
new file mode 100644
index 000000000..1927bd32f
--- /dev/null
+++ b/docs/markdown/snippets/external_project_devenv.md
@@ -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.
diff --git a/mesonbuild/modules/external_project.py b/mesonbuild/modules/external_project.py
index fb82a384d..9e283e026 100644
--- a/mesonbuild/modules/external_project.py
+++ b/mesonbuild/modules/external_project.py
@@ -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)