Skip to content

Commit

Permalink
envconfig: add pkg_config_path property
Browse files Browse the repository at this point in the history
In order to unify the use of sysroot in the cross-file,
the pkg_config_path can now be passed directly in the file.
  • Loading branch information
Stéphane Cerveau committed Jan 14, 2020
1 parent 71bbcc7 commit 8c0af70
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/markdown/Cross-compilation.md
Expand Up @@ -138,6 +138,7 @@ has_function_printf = true
c_args = ['-DCROSS=1', '-DSOMETHING=3']
c_link_args = ['-some_link_arg']
sys_root = '/some/path'
pkg_config_libdir = '/some/path/lib/pkgconfig'
```

In most cases you don't need the size and alignment settings, Meson
Expand All @@ -153,7 +154,8 @@ single string (i.e. not as `'-DCROSS=1 -DSOMETHING=3'`).
system path (the system that will run the compiled binaries). This is used
internally by Meson to set the PKG_CONFIG_SYSROOT_DIR environment variable
for pkg-config. If this is unset the host system is assumed to share a root
with the build system.
with the build system. The 'pkg_config_libdir' property may point to a list
of path used by pkg-config to get the cross build dependencies.

One important thing to note, if you did not define an `exe_wrapper` in
the previous section, is that Meson will make a best-effort guess at
Expand Down
7 changes: 6 additions & 1 deletion mesonbuild/dependencies/base.py
Expand Up @@ -693,10 +693,15 @@ def _call_pkgbin(self, args, env=None):
sysroot = self.env.properties[self.for_machine].get_sys_root()
if sysroot:
env['PKG_CONFIG_SYSROOT_DIR'] = sysroot
new_pkg_config_path = ':'.join([p for p in extra_paths])
new_pkg_config_path = os.pathsep.join([p for p in extra_paths])
mlog.debug('PKG_CONFIG_PATH: ' + new_pkg_config_path)
env['PKG_CONFIG_PATH'] = new_pkg_config_path

pkg_config_libdir_prop = self.env.properties[self.for_machine].get_pkg_config_libdir()
if pkg_config_libdir_prop:
new_pkg_config_libdir = os.pathsep.join([p for p in pkg_config_libdir_prop])
env['PKG_CONFIG_LIBDIR'] = new_pkg_config_libdir

fenv = frozenset(env.items())
targs = tuple(args)
cache = PkgConfigDependency.pkgbin_cache
Expand Down
3 changes: 3 additions & 0 deletions mesonbuild/envconfig.py
Expand Up @@ -140,6 +140,9 @@ def get_root(self) -> T.Optional[T.Union[str, T.List[str]]]:
def get_sys_root(self) -> T.Optional[T.Union[str, T.List[str]]]:
return self.properties.get('sys_root', None)

def get_pkg_config_libdir(self) -> T.Optional[T.Union[str, T.List[str]]]:
return self.properties.get('pkg_config_libdir', None)

def __eq__(self, other: T.Any) -> 'T.Union[bool, NotImplemented]':
if isinstance(other, type(self)):
return self.properties == other.properties
Expand Down

0 comments on commit 8c0af70

Please sign in to comment.