diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-07-21 23:05:17 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2020-07-30 18:59:10 +0300 |
commit | 40c197d524181713968ac5a1f052671744915c62 (patch) | |
tree | 4c2ce61788da9051f7ebc6b45a26c11cd3e4466e /test cases/common | |
parent | bbf8533a97481685d6e840de3d44372bae5d620e (diff) | |
download | meson-40c197d524181713968ac5a1f052671744915c62.zip meson-40c197d524181713968ac5a1f052671744915c62.tar.gz meson-40c197d524181713968ac5a1f052671744915c62.tar.bz2 |
pkgconfig: Fix various corner cases
See unit tests for the exact scenarios this PR fixes.
Diffstat (limited to 'test cases/common')
-rw-r--r-- | test cases/common/47 pkgconfig-gen/meson.build | 36 | ||||
-rw-r--r-- | test cases/common/47 pkgconfig-gen/simple5.c | 6 | ||||
-rw-r--r-- | test cases/common/47 pkgconfig-gen/test.json | 6 |
3 files changed, 47 insertions, 1 deletions
diff --git a/test cases/common/47 pkgconfig-gen/meson.build b/test cases/common/47 pkgconfig-gen/meson.build index eb2afe4..8c16cd5 100644 --- a/test cases/common/47 pkgconfig-gen/meson.build +++ b/test cases/common/47 pkgconfig-gen/meson.build @@ -1,5 +1,12 @@ project('pkgconfig-gen', 'c') +# Some CI runners does not have zlib, just skip them as we need some common +# external dependency. +cc = meson.get_compiler('c') +if not cc.find_library('z', required: false).found() + error('MESON_SKIP_TEST: zlib missing') +endif + # First check we have pkg-config >= 0.29 pkgconfig = find_program('pkg-config', required: false) if not pkgconfig.found() @@ -59,3 +66,32 @@ pkgg.generate( version : libver, dataonly: true ) + +# Regression test for 2 cases: +# - link_whole from InternalDependency used to be ignored, but we should still +# recurse to add libraries they link to. In this case it must add `-lsimple1` +# in generated pc file. +# - dependencies from InternalDependency used to be ignored. In this it must add +# `-lz` in generated pc file. +simple1 = shared_library('simple1', 'simple.c') +stat1 = static_library('stat1', 'simple.c', link_with: simple1) +dep = declare_dependency(link_whole: stat1, dependencies: cc.find_library('z')) +simple2 = library('simple2', 'simple.c') +pkgg.generate(simple2, libraries: dep) + +# Regression test: as_system() does a deepcopy() of the InternalDependency object +# which caused `-lsimple3` to be duplicated because generator used to compare +# Target instances instead of their id. +simple3 = shared_library('simple3', 'simple.c') +dep1 = declare_dependency(link_with: simple3) +dep2 = dep1.as_system() +pkgg.generate(libraries: [dep1, dep2], + name: 'simple3', + description: 'desc') + +# Regression test: stat2 is both link_with and link_whole, it should not appear +# in generated pc file. +stat2 = static_library('stat2', 'simple.c', install: true) +simple4 = library('simple4', 'simple.c', link_with: stat2) +simple5 = library('simple5', 'simple5.c', link_with: simple4, link_whole: stat2) +pkgg.generate(simple5) diff --git a/test cases/common/47 pkgconfig-gen/simple5.c b/test cases/common/47 pkgconfig-gen/simple5.c new file mode 100644 index 0000000..9f924bd --- /dev/null +++ b/test cases/common/47 pkgconfig-gen/simple5.c @@ -0,0 +1,6 @@ +int simple5(void); + +int simple5(void) +{ + return 0; +} diff --git a/test cases/common/47 pkgconfig-gen/test.json b/test cases/common/47 pkgconfig-gen/test.json index 1c6a452..702e7fe 100644 --- a/test cases/common/47 pkgconfig-gen/test.json +++ b/test cases/common/47 pkgconfig-gen/test.json @@ -1,9 +1,13 @@ { "installed": [ {"type": "file", "file": "usr/include/simple.h"}, + {"type": "file", "file": "usr/lib/libstat2.a"}, {"type": "file", "file": "usr/lib/pkgconfig/simple.pc"}, {"type": "file", "file": "usr/lib/pkgconfig/libfoo.pc"}, {"type": "file", "file": "usr/lib/pkgconfig/libhello.pc"}, - {"type": "file", "file": "usr/lib/pkgconfig/libhello_nolib.pc"} + {"type": "file", "file": "usr/lib/pkgconfig/libhello_nolib.pc"}, + {"type": "file", "file": "usr/lib/pkgconfig/simple2.pc"}, + {"type": "file", "file": "usr/lib/pkgconfig/simple3.pc"}, + {"type": "file", "file": "usr/lib/pkgconfig/simple5.pc"} ] } |