Add library with generated_pc and PkgConfigDependency support to pkgconfig.generate()

pull/3131/head
Aleksey Filippov 7 years ago
parent be6cedb491
commit d6b5d7fe9f
  1. 24
      mesonbuild/modules/pkgconfig.py
  2. 8
      run_unittests.py
  3. 14
      test cases/common/51 pkgconfig-gen/dependencies/meson.build
  4. 6
      test cases/common/51 pkgconfig-gen/meson.build

@ -44,10 +44,30 @@ class DependenciesHelper:
self.priv_reqs += reqs
def add_pub_reqs(self, reqs):
self.pub_reqs += mesonlib.stringlistify(reqs)
self.pub_reqs += self._process_reqs(reqs)
def add_priv_reqs(self, reqs):
self.priv_reqs += mesonlib.stringlistify(reqs)
self.priv_reqs += self._process_reqs(reqs)
def _process_reqs(self, reqs):
'''Returns string names of requirements'''
processed_reqs = []
for obj in mesonlib.listify(reqs, unholder=True):
if hasattr(obj, 'generated_pc'):
processed_reqs.append(obj.generated_pc)
elif hasattr(obj, 'pcdep'):
pcdeps = mesonlib.listify(obj.pcdep)
processed_reqs += [i.name for i in pcdeps]
elif isinstance(obj, dependencies.PkgConfigDependency):
if obj.found():
processed_reqs.append(obj.name)
elif isinstance(obj, str):
processed_reqs.append(obj)
else:
raise mesonlib.MesonException('requires argument not a string, '
'library with pkgconfig-generated file '
'or pkgconfig-dependency object.')
return processed_reqs
def add_cflags(self, cflags):
self.cflags += mesonlib.stringlistify(cflags)

@ -2169,6 +2169,14 @@ class LinuxlikeTests(BasePlatformTests):
'-llibinternal', '-lcustom2',
'-lfoo']))
cmd = ['pkg-config', 'requires-test']
out = self._run(cmd + ['--print-requires']).strip().split()
self.assertEqual(sorted(out), sorted(['libexposed', 'libfoo', 'libhello']))
cmd = ['pkg-config', 'requires-private-test']
out = self._run(cmd + ['--print-requires-private']).strip().split()
self.assertEqual(sorted(out), sorted(['libexposed', 'libfoo', 'libhello']))
def test_pkg_unfound(self):
testdir = os.path.join(self.unit_test_dir, '22 unfound pkgconfig')
self.init(testdir)

@ -36,3 +36,17 @@ pkgg.generate(libraries : [main_lib, exposed_lib, threads_dep , custom_dep],
filebase : 'dependency-test',
description : 'A dependency test.'
)
pkgg.generate(
name : 'requires-test',
version : '1.0',
description : 'Dependency Requires field test.',
requires : [exposed_lib, pc_dep, 'libhello'],
)
pkgg.generate(
name : 'requires-private-test',
version : '1.0',
description : 'Dependency Requires.private field test.',
requires_private : [exposed_lib, pc_dep, 'libhello', notfound_dep],
)

@ -46,3 +46,9 @@ pkgg.generate(
description : 'A foo library.',
variables : ['foo=bar', 'datadir=${prefix}/data']
)
pkgg.generate(
name : 'libhello',
description : 'A minimalistic pkgconfig file.',
version : libver,
)

Loading…
Cancel
Save