pkgconfig: fix use of uninstalled libraries

Prepend the path of uninstalled libraries to PKG_CONFIG_PATH
so they have preference over other search paths set by the
user.

see: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3247
pull/13819/head
Andoni Morales Alastruey 10 months ago committed by Xavier Claessens
parent f0a86b2b8c
commit c02e0b7b1e
  1. 2
      mesonbuild/dependencies/pkgconfig.py
  2. 36
      unittests/linuxliketests.py

@ -260,7 +260,7 @@ class PkgConfigCLI(PkgConfigInterface):
if uninstalled:
uninstalled_path = Path(self.env.get_build_dir(), 'meson-uninstalled').as_posix()
if uninstalled_path not in extra_paths:
extra_paths.append(uninstalled_path)
extra_paths.insert(0, uninstalled_path)
env.set('PKG_CONFIG_PATH', extra_paths)
sysroot = self.env.properties[self.for_machine].get_sys_root()
if sysroot:

@ -1141,6 +1141,42 @@ class LinuxlikeTests(BasePlatformTests):
pkg_config_path = env.coredata.optstore.get_value('pkg_config_path')
self.assertEqual(pkg_config_path, [pkg_dir])
def test_pkgconfig_uninstalled_env_added(self):
'''
Checks that the meson-uninstalled dir is added to PKG_CONFIG_PATH
'''
testdir = os.path.join(self.unit_test_dir, '111 pkgconfig duplicate path entries')
meson_uninstalled_dir = os.path.join(self.builddir, 'meson-uninstalled')
env = get_fake_env(testdir, self.builddir, self.prefix)
newEnv = PkgConfigInterface.setup_env({}, env, MachineChoice.HOST, uninstalled=True)
pkg_config_path_dirs = newEnv['PKG_CONFIG_PATH'].split(os.pathsep)
self.assertEqual(len(pkg_config_path_dirs), 1)
self.assertEqual(pkg_config_path_dirs[0], meson_uninstalled_dir)
def test_pkgconfig_uninstalled_env_prepended(self):
'''
Checks that the meson-uninstalled dir is prepended to PKG_CONFIG_PATH
'''
testdir = os.path.join(self.unit_test_dir, '111 pkgconfig duplicate path entries')
meson_uninstalled_dir = os.path.join(self.builddir, 'meson-uninstalled')
external_pkg_config_path_dir = os.path.join('usr', 'local', 'lib', 'pkgconfig')
env = get_fake_env(testdir, self.builddir, self.prefix)
env.coredata.set_options({OptionKey('pkg_config_path'): external_pkg_config_path_dir},
subproject='')
newEnv = PkgConfigInterface.setup_env({}, env, MachineChoice.HOST, uninstalled=True)
pkg_config_path_dirs = newEnv['PKG_CONFIG_PATH'].split(os.pathsep)
self.assertEqual(pkg_config_path_dirs[0], meson_uninstalled_dir)
self.assertEqual(pkg_config_path_dirs[1], external_pkg_config_path_dir)
@skipIfNoPkgconfig
def test_pkgconfig_internal_libraries(self):
'''

Loading…
Cancel
Save