Fix pkgconfig.generate handling of BothLibraries dependencies

Was caused by 7b3169f. Fixes #13657.
pull/13664/head
Charles Brunet 3 months ago committed by Dylan Baker
parent 68d620ea8e
commit 8a641cac5f
  1. 7
      mesonbuild/modules/pkgconfig.py
  2. 19
      test cases/common/278 pkgconfig-gen/meson.build
  3. 6
      test cases/common/278 pkgconfig-gen/simple.c
  4. 6
      test cases/common/278 pkgconfig-gen/simple.h
  5. 2
      test cases/common/278 pkgconfig-gen/simple2/exports.def
  6. 2
      test cases/common/278 pkgconfig-gen/simple2/meson.build
  7. 5
      test cases/common/278 pkgconfig-gen/simple2/simple2.c
  8. 6
      test cases/common/278 pkgconfig-gen/simple2/simple2.h
  9. 15
      test cases/common/278 pkgconfig-gen/test.json

@ -195,6 +195,13 @@ class DependenciesHelper:
if obj.found():
if obj.objects:
raise mesonlib.MesonException('.pc file cannot refer to individual object files.')
# Ensure BothLibraries are resolved:
if self.pub_libs and isinstance(self.pub_libs[0], build.StaticLibrary):
obj = obj.get_as_static(recursive=True)
else:
obj = obj.get_as_shared(recursive=True)
processed_libs += obj.get_link_args()
processed_cflags += obj.get_compile_args()
self._add_lib_dependencies(obj.libraries, obj.whole_libraries, obj.ext_deps, public, private_external_deps=True)

@ -0,0 +1,19 @@
project('pkgconfig-get', 'c')
pkgg = import('pkgconfig')
subdir('simple2')
lib = library('simple', 'simple.c', dependencies: lib_dep)
libver = '1.0'
h = install_headers('simple.h')
pkgg.generate(
lib,
version : libver,
name : 'libsimple',
filebase : 'simple',
description : 'A simple demo library.',
libraries: [lib_dep],
)

@ -0,0 +1,6 @@
#include"simple.h"
#include <simple2.h>
int simple_function(void) {
return simple_simple_function();
}

@ -0,0 +1,6 @@
#ifndef SIMPLE_H_
#define SIMPLE_H_
int simple_function(void);
#endif

@ -0,0 +1,2 @@
EXPORTS
simple_simple_function @1

@ -0,0 +1,2 @@
lib2 = library('simple2', 'simple2.c', vs_module_defs: 'exports.def')
lib_dep = declare_dependency(link_with: lib2, include_directories: include_directories('.'))

@ -0,0 +1,5 @@
#include"simple2.h"
int simple_simple_function(void) {
return 42;
}

@ -0,0 +1,6 @@
#ifndef SIMPLE2_H_
#define SIMPLE2_H_
int simple_simple_function(void);
#endif

@ -0,0 +1,15 @@
{
"installed": [
{ "type": "file", "file": "usr/include/simple.h"},
{ "type": "file", "file": "usr/lib/pkgconfig/simple.pc"}
],
"matrix": {
"options": {
"default_library": [
{ "val": "shared" },
{ "val": "static" },
{ "val": "both" }
]
}
}
}
Loading…
Cancel
Save