From c385f7973777e0e7b7e4694d69d6584e2ceae69f Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sat, 17 Mar 2018 00:37:05 +0200 Subject: Do not leak out private dependencies for shared libraries. --- mesonbuild/modules/pkgconfig.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'mesonbuild/modules/pkgconfig.py') diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 2f4dfae..5254731 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -93,7 +93,17 @@ class DependenciesHelper: if obj.found(): processed_libs += obj.get_link_args() processed_cflags += obj.get_compile_args() - elif isinstance(obj, (build.SharedLibrary, build.StaticLibrary)): + elif isinstance(obj, build.SharedLibrary): + processed_libs.append(obj) + elif isinstance(obj, build.StaticLibrary): + # Due to a "feature" in pkgconfig, it leaks out private dependencies. + # Thus we will not add them to the pc file unless the target + # we are processing is a static library. + # + # This way (hopefully) "pkgconfig --libs --static foobar" works + # and "pkgconfig --cflags/--libs foobar" does not have any trace + # of dependencies that the build file creator has not explicitly + # added to the dependency list. processed_libs.append(obj) if public: if not hasattr(obj, 'generated_pc'): -- cgit v1.1 From cf5f1a83d55d05412e29058844e4fda5e420553b Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sat, 17 Mar 2018 19:44:16 +0200 Subject: Fix existing tests. --- mesonbuild/modules/pkgconfig.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mesonbuild/modules/pkgconfig.py') diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 5254731..bd89670 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -95,6 +95,9 @@ class DependenciesHelper: processed_cflags += obj.get_compile_args() elif isinstance(obj, build.SharedLibrary): processed_libs.append(obj) + if public: + if not hasattr(obj, 'generated_pc'): + obj.generated_pc = self.name elif isinstance(obj, build.StaticLibrary): # Due to a "feature" in pkgconfig, it leaks out private dependencies. # Thus we will not add them to the pc file unless the target -- cgit v1.1