devenv: Set GI_TYPELIB_PATH and LD_LIBRARY_PATH (#8548)

pull/8573/head
Xavier Claessens 4 years ago committed by GitHub
parent 1be13710ad
commit a9e9b7c750
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      docs/markdown/Commands.md
  2. 8
      docs/markdown/snippets/devenv.md
  3. 21
      mesonbuild/backend/backends.py
  4. 19
      mesonbuild/modules/gnome.py

@ -295,5 +295,12 @@ These variables are set in environment in addition to those set using `meson.add
- `PATH` includes every directory where there is an executable that would be
installed into `bindir`. On windows it also includes every directory where there
is a DLL needed to run those executables.
- `LD_LIBRARY_PATH` includes every directory where there is a shared library that
would be installed into `libdir`. This allows to run system application using
custom build of some libraries. For example running system GEdit when building
GTK from git. On OSX the environment variable is `DYLD_LIBRARY_PATH` and
`PATH` on Windows.
- `GI_TYPELIB_PATH` includes every directory where a GObject Introspection
typelib is built. This is automatically set when using `gnome.generate_gir()`.
{{ devenv_arguments.inc }}

@ -26,4 +26,10 @@ These variables are set in environment in addition to those set using `meson.add
- `PATH` includes every directory where there is an executable that would be
installed into `bindir`. On windows it also includes every directory where there
is a DLL needed to run those executables.
- `LD_LIBRARY_PATH` includes every directory where there is a shared library that
would be installed into `libdir`. This allows to run system application using
custom build of some libraries. For example running system GEdit when building
GTK from git. On OSX the environment variable is `DYLD_LIBRARY_PATH` and
`PATH` on Windows.
- `GI_TYPELIB_PATH` includes every directory where a GObject Introspection
typelib is built. This is automatically set when using `gnome.generate_gir()`.

@ -1496,18 +1496,33 @@ class Backend:
def get_devenv(self) -> build.EnvironmentVariables:
env = build.EnvironmentVariables()
extra_paths = set()
library_paths = set()
for t in self.build.get_targets().values():
cross_built = not self.environment.machines.matches_build_machine(t.for_machine)
can_run = not cross_built or not self.environment.need_exe_wrapper()
in_bindir = t.should_install() and not t.get_install_dir(self.environment)[1]
if isinstance(t, build.Executable) and can_run and in_bindir:
in_default_dir = t.should_install() and not t.get_install_dir(self.environment)[1]
if not can_run or not in_default_dir:
continue
tdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(t))
if isinstance(t, build.Executable):
# Add binaries that are going to be installed in bindir into PATH
# so they get used by default instead of searching on system when
# in developer environment.
extra_paths.add(os.path.join(self.environment.get_build_dir(), self.get_target_dir(t)))
extra_paths.add(tdir)
if mesonlib.is_windows() or mesonlib.is_cygwin():
# On windows we cannot rely on rpath to run executables from build
# directory. We have to add in PATH the location of every DLL needed.
extra_paths.update(self.determine_windows_extra_paths(t, []))
elif isinstance(t, build.SharedLibrary):
# Add libraries that are going to be installed in libdir into
# LD_LIBRARY_PATH. This allows running system applications using
# that library.
library_paths.add(tdir)
if mesonlib.is_windows() or mesonlib.is_cygwin():
extra_paths.update(library_paths)
elif mesonlib.is_osx():
env.prepend('DYLD_LIBRARY_PATH', list(library_paths))
else:
env.prepend('LD_LIBRARY_PATH', list(library_paths))
env.prepend('PATH', list(extra_paths))
return env

@ -50,11 +50,13 @@ gresource_dep_needed_version = '>= 2.51.1'
native_glib_version = None
class GnomeModule(ExtensionModule):
gir_dep = None
install_glib_compile_schemas = False
install_gio_querymodules = []
install_gtk_update_icon_cache = False
def __init__(self, interpreter: 'Interpreter') -> None:
super().__init__(interpreter)
self.gir_dep = None
self.install_glib_compile_schemas = False
self.install_gio_querymodules = []
self.install_gtk_update_icon_cache = False
self.devenv = None
@staticmethod
def _get_native_glib_version(state):
@ -480,6 +482,12 @@ class GnomeModule(ExtensionModule):
return girtarget
def _devenv_append(self, varname: str, value: str) -> None:
if self.devenv is None:
self.devenv = build.EnvironmentVariables()
self.interpreter.build.devenv.append(self.devenv)
self.devenv.append(varname, [value])
def _get_gir_dep(self, state):
if not self.gir_dep:
self.gir_dep = self._get_native_dep(state, 'gobject-introspection-1.0')
@ -884,6 +892,7 @@ class GnomeModule(ExtensionModule):
typelib_cmd += ["--includedir=" + incdir]
typelib_target = self._make_typelib_target(state, typelib_output, typelib_cmd, kwargs)
self._devenv_append('GI_TYPELIB_PATH', os.path.join(state.environment.get_build_dir(), state.subdir))
rv = [scan_target, typelib_target]

Loading…
Cancel
Save