pkgconfig: Process private libraries like regular ones

pull/862/head
Guillaume Poirier-Morency 8 years ago
parent 9429183c1d
commit 9ebc140832
  1. 48
      mesonbuild/modules/pkgconfig.py

@ -63,23 +63,25 @@ class PkgConfigModule:
'Requires.private: {}\n'.format(' '.join(priv_reqs))) 'Requires.private: {}\n'.format(' '.join(priv_reqs)))
if len(conflicts) > 0: if len(conflicts) > 0:
ofile.write('Conflicts: {}\n'.format(' '.join(conflicts))) ofile.write('Conflicts: {}\n'.format(' '.join(conflicts)))
ofile.write('Libs: -L${libdir}') def generate_libs_flags(libs):
msg = 'Library target {0!r} has {1!r} set. Compilers ' \ msg = 'Library target {0!r} has {1!r} set. Compilers ' \
'may not find it from its \'-l{2}\' linker flag in the ' \ 'may not find it from its \'-l{2}\' linker flag in the ' \
'{3!r} pkg-config file.' '{3!r} pkg-config file.'
for l in libraries: for l in libs:
if l.custom_install_dir: if l.custom_install_dir:
ofile.write(' -L${prefix}/%s ' % l.custom_install_dir) yield '-L${prefix}/%s ' % l.custom_install_dir
lname = self._get_lname(l, msg, pcfile) else:
# If using a custom suffix, the compiler may not be able to yield '-L${libdir}'
# find the library lname = self._get_lname(l, msg, pcfile)
if l.name_suffix_set: # If using a custom suffix, the compiler may not be able to
mlog.log(mlog.red('WARNING:'), msg.format(l.name, 'name_suffix', lname, pcfile)) # find the library
ofile.write(' -l{} '.format(lname)) if l.name_suffix_set:
ofile.write('\n') mlog.log(mlog.red('WARNING:'), msg.format(l.name, 'name_suffix', lname, pcfile))
yield '-l%s' % lname
if len(libraries) > 0:
ofile.write('Libs: {}\n'.format(' '.join(generate_libs_flags(libraries))))
if len(priv_libs) > 0: if len(priv_libs) > 0:
ofile.write( ofile.write('Libs.private: {}\n'.format(' '.join(generate_libs_flags(priv_libs))))
'Libs.private: -L${libdir} {}\n'.format(' '.join(priv_libs)))
ofile.write('Cflags:') ofile.write('Cflags:')
for h in subdirs: for h in subdirs:
if h == '.': if h == '.':
@ -88,10 +90,7 @@ class PkgConfigModule:
ofile.write(os.path.join('-I${includedir}', h)) ofile.write(os.path.join('-I${includedir}', h))
ofile.write('\n') ofile.write('\n')
def generate(self, state, args, kwargs): def process_libs(self, libs):
if len(args) > 0:
raise mesonlib.MesonException('Pkgconfig_gen takes no positional arguments.')
libs = kwargs.get('libraries', [])
if not isinstance(libs, list): if not isinstance(libs, list):
libs = [libs] libs = [libs]
processed_libs = [] processed_libs = []
@ -101,7 +100,13 @@ class PkgConfigModule:
if not isinstance(l, (build.SharedLibrary, build.StaticLibrary)): if not isinstance(l, (build.SharedLibrary, build.StaticLibrary)):
raise mesonlib.MesonException('Library argument not a library object.') raise mesonlib.MesonException('Library argument not a library object.')
processed_libs.append(l) processed_libs.append(l)
libs = processed_libs return processed_libs
def generate(self, state, args, kwargs):
if len(args) > 0:
raise mesonlib.MesonException('Pkgconfig_gen takes no positional arguments.')
libs = self.process_libs(kwargs.get('libraries', []))
priv_libs = self.process_libs(kwargs.get('libraries_private', []))
subdirs = mesonlib.stringlistify(kwargs.get('subdirs', ['.'])) subdirs = mesonlib.stringlistify(kwargs.get('subdirs', ['.']))
version = kwargs.get('version', '') version = kwargs.get('version', '')
if not isinstance(version, str): if not isinstance(version, str):
@ -121,7 +126,6 @@ class PkgConfigModule:
pub_reqs = mesonlib.stringlistify(kwargs.get('requires', [])) pub_reqs = mesonlib.stringlistify(kwargs.get('requires', []))
priv_reqs = mesonlib.stringlistify(kwargs.get('requires_private', [])) priv_reqs = mesonlib.stringlistify(kwargs.get('requires_private', []))
conflicts = mesonlib.stringlistify(kwargs.get('conflicts', [])) conflicts = mesonlib.stringlistify(kwargs.get('conflicts', []))
priv_libs = mesonlib.stringlistify(kwargs.get('libraries_private', []))
pcfile = filebase + '.pc' pcfile = filebase + '.pc'
pkgroot = kwargs.get('install_dir',None) pkgroot = kwargs.get('install_dir',None)
if pkgroot is None: if pkgroot is None:

Loading…
Cancel
Save