diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index f18decf67..c3183db65 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -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(): diff --git a/test cases/common/51 pkgconfig-gen/meson.build b/test cases/common/51 pkgconfig-gen/meson.build index a54fd6633..bed721e0c 100644 --- a/test cases/common/51 pkgconfig-gen/meson.build +++ b/test cases/common/51 pkgconfig-gen/meson.build @@ -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'], )