aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-03-04 13:09:05 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2017-03-04 09:12:51 -0500
commita24651f33a925c5860a58c3fb8e7b5ec2efbccbd (patch)
tree01b8f3dedf1ec4147f25ebaa6a110f454918f1ff /mesonbuild
parent2ecb26c9ae093a16c1f79b3b81ca0c66c054f579 (diff)
downloadmeson-a24651f33a925c5860a58c3fb8e7b5ec2efbccbd.zip
meson-a24651f33a925c5860a58c3fb8e7b5ec2efbccbd.tar.gz
meson-a24651f33a925c5860a58c3fb8e7b5ec2efbccbd.tar.bz2
darwin: Also add the major version in the dylib
And symlink to the unversioned library for build-time linking. https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html#//apple_ref/doc/uid/TP40002013-SW2 Unlike Autotools, we do not add the minor or micro version in the filename because the Apple documentation says you must embed that inside the library with -current_version.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/build.py33
1 files changed, 20 insertions, 13 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index fd01f77..bf692e1 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1114,10 +1114,13 @@ class SharedLibrary(BuildTarget):
elif for_darwin(is_cross, env):
prefix = 'lib'
suffix = 'dylib'
- # libfoo.dylib
- self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
- # On OS X, the filename should never have the soversion
- # See: https://github.com/mesonbuild/meson/pull/680
+ # On macOS, the filename can only contain the major version
+ if self.soversion:
+ # libfoo.X.dylib
+ self.filename_tpl = '{0.prefix}{0.name}.{0.soversion}.{0.suffix}'
+ else:
+ # libfoo.dylib
+ self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
else:
prefix = 'lib'
suffix = 'so'
@@ -1191,24 +1194,28 @@ class SharedLibrary(BuildTarget):
If the versioned library name is libfoo.so.0.100.0, aliases are:
* libfoo.so.0 (soversion) -> libfoo.so.0.100.0
* libfoo.so (unversioned; for linking) -> libfoo.so.0
+ Same for dylib:
+ * libfoo.dylib (unversioned; for linking) -> libfoo.0.dylib
"""
aliases = {}
- # Aliases are only useful with .so libraries. Also if the .so library
- # ends with .so (no versioning), we don't need aliases.
- if self.suffix != 'so' or self.filename.endswith('.so'):
+ # Aliases are only useful with .so and .dylib libraries. Also if
+ # there's no self.soversion (no versioning), we don't need aliases.
+ if self.suffix not in ('so', 'dylib') or not self.soversion:
return {}
- # If ltversion != soversion we create an soversion alias:
+ # With .so libraries, the minor and micro versions are also in the
+ # filename. If ltversion != soversion we create an soversion alias:
# libfoo.so.0 -> libfoo.so.0.100.0
- if self.ltversion and self.ltversion != self.soversion:
- if not self.soversion:
- # This is done in self.process_kwargs()
- raise AssertionError('BUG: If library version is defined, soversion must have been defined')
+ # Where libfoo.so.0.100.0 is the actual library
+ if self.suffix == 'so' and self.ltversion and self.ltversion != self.soversion:
alias_tpl = self.filename_tpl.replace('ltversion', 'soversion')
ltversion_filename = alias_tpl.format(self)
aliases[ltversion_filename] = self.filename
+ # libfoo.so.0/libfoo.0.dylib is the actual library
else:
ltversion_filename = self.filename
- # Unversioned alias: libfoo.so -> libfoo.so.0
+ # Unversioned alias:
+ # libfoo.so -> libfoo.so.0
+ # libfoo.dylib -> libfoo.0.dylib
aliases[self.basic_filename_tpl.format(self)] = ltversion_filename
return aliases