diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-10-12 21:14:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-12 21:14:09 +0300 |
commit | f194914b9fe0042cce83ee4371ca3ccc2efc7120 (patch) | |
tree | ec661f956c9bf48094bc29374f4b8c828a2772ec | |
parent | cb21c72ac848c3dec4de0b26fef96a2319bdefda (diff) | |
parent | 674b520206422f546131aa5218d0b2ffddccbf37 (diff) | |
download | meson-f194914b9fe0042cce83ee4371ca3ccc2efc7120.zip meson-f194914b9fe0042cce83ee4371ca3ccc2efc7120.tar.gz meson-f194914b9fe0042cce83ee4371ca3ccc2efc7120.tar.bz2 |
Merge pull request #896 from centricular/pkgconfig-check-prefix-suffix
pkgconfig: Warn if library has name_prefix/suffix set
-rw-r--r-- | mesonbuild/build.py | 4 | ||||
-rw-r--r-- | mesonbuild/modules/pkgconfig.py | 18 |
2 files changed, 19 insertions, 3 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index f212fe4..4fc8536 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -229,6 +229,8 @@ class BuildTarget(): self.include_dirs = [] self.link_targets = [] self.link_depends = [] + self.name_prefix_set = False + self.name_suffix_set = False self.filename = 'no_name' # The file with debugging symbols self.debug_filename = None @@ -514,6 +516,7 @@ class BuildTarget(): elif not isinstance(name_prefix, str): raise InvalidArguments('name_prefix must be a string.') self.prefix = name_prefix + self.name_prefix_set = True if 'name_suffix' in kwargs: name_suffix = kwargs['name_suffix'] if isinstance(name_suffix, list): @@ -523,6 +526,7 @@ class BuildTarget(): if not isinstance(name_suffix, str): raise InvalidArguments('name_suffix must be a string.') self.suffix = name_suffix + self.name_suffix_set = True if isinstance(self, StaticLibrary): # You can't disable PIC on OS X. The compiler ignores -fno-PIC. # PIC is always on for Windows (all code is position-independent diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 3bf7658..daa11ea 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -14,15 +14,16 @@ from .. import coredata, build from .. import mesonlib +from .. import mlog import os class PkgConfigModule: - def generate_pkgconfig_file(self, state, libraries, subdirs, name, description, version, filebase, + def generate_pkgconfig_file(self, state, libraries, subdirs, name, description, version, pcfile, pub_reqs, priv_reqs, priv_libs): coredata = state.environment.get_coredata() outdir = state.environment.scratch_dir - fname = os.path.join(outdir, filebase + '.pc') + fname = os.path.join(outdir, pcfile) with open(fname, 'w') as ofile: ofile.write('prefix=%s\n' % coredata.get_builtin_option('prefix')) ofile.write('libdir=${prefix}/%s\n' % @@ -43,9 +44,20 @@ class PkgConfigModule: ofile.write( 'Libraries.private: {}\n'.format(' '.join(priv_libs))) ofile.write('Libs: -L${libdir} ') + msg = 'Library target {0!r} has {1!r} set. Compilers ' \ + 'may not find it from its \'-l{0}\' linker flag in the ' \ + '{2!r} pkg-config file.' for l in libraries: if l.custom_install_dir: ofile.write('-L${prefix}/%s ' % l.custom_install_dir) + # Warn, but not if the filename starts with 'lib'. This can + # happen, for instance, if someone really wants to use the + # 'lib' prefix on all systems, not just on UNIX, or if the the + # target name itself starts with 'lib'. + if l.name_prefix_set and not l.filename.startswith('lib'): + mlog.log(mlog.red('WARNING:'), msg.format(l.name, 'name_prefix', pcfile)) + if l.name_suffix_set: + mlog.log(mlog.red('WARNING:'), msg.format(l.name, 'name_suffix', pcfile)) ofile.write('-l%s ' % l.name) ofile.write('\n') ofile.write('CFlags: ') @@ -92,7 +104,7 @@ class PkgConfigModule: pkgroot = os.path.join(state.environment.coredata.get_builtin_option('libdir'), 'pkgconfig') if not isinstance(pkgroot, str): raise mesonlib.MesonException('Install_dir must be a string.') - self.generate_pkgconfig_file(state, libs, subdirs, name, description, version, filebase, + self.generate_pkgconfig_file(state, libs, subdirs, name, description, version, pcfile, pub_reqs, priv_reqs, priv_libs) return build.Data(False, state.environment.get_scratch_dir(), [pcfile], pkgroot) |