diff options
| author | Andoni Morales Alastruey <ylatuya@gmail.com> | 2024-01-24 17:16:09 +0100 |
|---|---|---|
| committer | Xavier Claessens <xclaesse@gmail.com> | 2024-10-23 08:04:50 -0400 |
| commit | c02e0b7b1e2499f3ae18d26e443e18043fff3046 (patch) | |
| tree | d31b33728525fbbbd0b28d480ea1222db184c042 | |
| parent | f0a86b2b8c05c091e3fc03c2982affbd3ec7f59e (diff) | |
| download | meson-c02e0b7b1e2499f3ae18d26e443e18043fff3046.tar.gz | |
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
| -rw-r--r-- | mesonbuild/dependencies/pkgconfig.py | 2 | ||||
| -rw-r--r-- | unittests/linuxliketests.py | 36 |
2 files changed, 37 insertions, 1 deletions
diff --git a/mesonbuild/dependencies/pkgconfig.py b/mesonbuild/dependencies/pkgconfig.py index bc24f760f..c6e6a5e4f 100644 --- a/mesonbuild/dependencies/pkgconfig.py +++ b/mesonbuild/dependencies/pkgconfig.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: diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py index 3ac980760..1e9e38d1b 100644 --- a/unittests/linuxliketests.py +++ b/unittests/linuxliketests.py @@ -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): ''' |
