Can set requires manually into generated pc files.

pull/493/head
Jussi Pakkanen 9 years ago
parent 74265135bd
commit c0c9a96c36
  1. 12
      mesonbuild/modules/pkgconfig.py
  2. 4
      test cases/common/51 pkgconfig-gen/meson.build

@ -21,7 +21,8 @@ class PkgConfigModule:
def print_hello(self, state, args, kwargs):
print('Hello from a Meson module')
def generate_pkgconfig_file(self, state, libraries, subdirs, name, description, version, filebase):
def generate_pkgconfig_file(self, state, libraries, subdirs, name, description, version, filebase,
pub_reqs, priv_reqs):
outdir = state.environment.scratch_dir
fname = os.path.join(outdir, filebase + '.pc')
ofile = open(fname, 'w')
@ -34,6 +35,10 @@ class PkgConfigModule:
ofile.write('Description: %s\n' % description)
if len(version) > 0:
ofile.write('Version: %s\n' % version)
if len(pub_reqs):
ofile.write('Requires: {}\n'.format(' '.join(pub_reqs)))
if len(priv_reqs):
ofile.write('Requires.private: {}\n'.format(' '.join(priv_reqs)))
ofile.write('Libs: -L${libdir} ')
for l in libraries:
ofile.write('-l%s ' % l.name)
@ -73,9 +78,12 @@ class PkgConfigModule:
description = kwargs.get('description', None)
if not isinstance(description, str):
raise coredata.MesonException('Description is not a string.')
pub_reqs = mesonlib.stringlistify(kwargs.get('requires', []))
priv_reqs = mesonlib.stringlistify(kwargs.get('requires_private', []))
pcfile = filebase + '.pc'
pkgroot = os.path.join(state.environment.coredata.get_builtin_option('libdir'), 'pkgconfig')
self.generate_pkgconfig_file(state, libs, subdirs, name, description, version, filebase)
self.generate_pkgconfig_file(state, libs, subdirs, name, description, version, filebase,
pub_reqs, priv_reqs)
return build.Data(False, state.environment.get_scratch_dir(), [pcfile], pkgroot)
def initialize():

@ -12,5 +12,7 @@ pkgg.generate(
version : libver,
name : 'libsimple',
filebase : 'simple',
description : 'A simple demo library.'
description : 'A simple demo library.',
requires : 'glib-2.0', # Not really, but only here to test that this works.
requires_private : ['gio-2.0', 'gobject-2.0'],
)

Loading…
Cancel
Save