From dd2e3bf446af0007fa62bf918d77c082f13dbf01 Mon Sep 17 00:00:00 2001 From: lilinzhe Date: Mon, 19 Jul 2021 15:24:44 +0800 Subject: pkg-config: support for `-l:libfoo.a` fixs: #9000 Meson not correctly process with -l:xxx.a link arguments in pkgconfig .pc file. see also:https://stackoverflow.com/questions/48532868/gcc-library-option-with-a-colon-llibevent-a with unit test, unit test will be partially skiped if pkg-config version < 0.28 . see: https://gitlab.freedesktop.org/pkg-config/pkg-config/-/blob/master/NEWS --- mesonbuild/dependencies/pkgconfig.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'mesonbuild/dependencies/pkgconfig.py') diff --git a/mesonbuild/dependencies/pkgconfig.py b/mesonbuild/dependencies/pkgconfig.py index 9786918..d047e81 100644 --- a/mesonbuild/dependencies/pkgconfig.py +++ b/mesonbuild/dependencies/pkgconfig.py @@ -276,6 +276,30 @@ class PkgConfigDependency(ExternalDependency): elif lib.startswith('-L'): # We already handled library paths above continue + elif lib.startswith('-l:'): + # see: https://stackoverflow.com/questions/48532868/gcc-library-option-with-a-colon-llibevent-a + # also : See the documentation of -lnamespec | --library=namespec in the linker manual + # https://sourceware.org/binutils/docs-2.18/ld/Options.html + + # Don't resolve the same -l:libfoo.a argument again + if lib in libs_found: + continue + libfilename = lib[3:] + foundname = None + for libdir in libpaths: + target = os.path.join(libdir, libfilename) + if os.path.exists(target): + foundname = target + break + if foundname is None: + if lib in libs_notfound: + continue + else: + mlog.warning('Library {!r} not found for dependency {!r}, may ' + 'not be successfully linked'.format(libfilename, self.name)) + libs_notfound.append(lib) + else: + lib = foundname elif lib.startswith('-l'): # Don't resolve the same -lfoo argument again if lib in libs_found: -- cgit v1.1