Add external dependencies to pc files only if found. Closes #2911.
This commit is contained in:
parent
714ac85d22
commit
5e4538fe63
|
@ -79,7 +79,7 @@ class DependenciesHelper:
|
|||
if not hasattr(obj, 'generated_pc'):
|
||||
obj.generated_pc = self.name
|
||||
self.add_priv_libs(obj.get_dependencies())
|
||||
self.add_priv_libs(obj.get_external_deps())
|
||||
self.add_priv_libs(self.strip_unfound(obj.get_external_deps()))
|
||||
elif isinstance(obj, str):
|
||||
processed_libs.append(obj)
|
||||
else:
|
||||
|
@ -87,6 +87,9 @@ class DependenciesHelper:
|
|||
|
||||
return processed_libs, processed_reqs, processed_cflags
|
||||
|
||||
def strip_unfound(self, deps):
|
||||
return [x for x in deps if not hasattr(x, 'found') or x.found()]
|
||||
|
||||
def remove_dups(self):
|
||||
self.pub_libs = list(set(self.pub_libs))
|
||||
self.pub_reqs = list(set(self.pub_reqs))
|
||||
|
|
|
@ -436,6 +436,7 @@ class BasePlatformTests(unittest.TestCase):
|
|||
# In case the directory is inside a symlinked directory, find the real
|
||||
# path otherwise we might not find the srcdir from inside the builddir.
|
||||
self.builddir = os.path.realpath(tempfile.mkdtemp())
|
||||
self.privatedir = os.path.join(self.builddir, 'meson-private')
|
||||
self.logdir = os.path.join(self.builddir, 'meson-logs')
|
||||
self.prefix = '/usr'
|
||||
self.libdir = os.path.join(self.prefix, 'lib')
|
||||
|
@ -2085,6 +2086,12 @@ class LinuxlikeTests(BasePlatformTests):
|
|||
'-llibinternal', '-lcustom2',
|
||||
'-lfoo']))
|
||||
|
||||
def test_pkg_unfound(self):
|
||||
testdir = os.path.join(self.unit_test_dir, '22 unfound pkgconfig')
|
||||
self.init(testdir)
|
||||
pcfile = open(os.path.join(self.privatedir, 'somename.pc')).read()
|
||||
self.assertFalse('blub_blob_blib' in pcfile)
|
||||
|
||||
def test_vala_c_warnings(self):
|
||||
'''
|
||||
Test that no warnings are emitted for C code generated by Vala. This
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
project('foobar', 'c')
|
||||
|
||||
unfound = dependency('blub_blob_blib', required : false)
|
||||
|
||||
pkgg = import('pkgconfig')
|
||||
|
||||
l = shared_library('somename', 'some.c',
|
||||
dependencies : unfound)
|
||||
|
||||
pkgg.generate(
|
||||
libraries : l,
|
||||
name : 'somename',
|
||||
version : '1.0.0',
|
||||
description : 'A test library.',
|
||||
)
|
|
@ -0,0 +1,3 @@
|
|||
int some() {
|
||||
return 6;
|
||||
}
|
Loading…
Reference in New Issue