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.
pull/1447/head
Nirbheek Chauhan 8 years ago committed by Jussi Pakkanen
parent 2ecb26c9ae
commit a24651f33a
  1. 33
      mesonbuild/build.py
  2. 3
      test cases/osx/2 library versions/installed_files.txt

@ -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

@ -1,4 +1,7 @@
usr/lib/libsome.dylib
usr/lib/libsome.0.dylib
usr/lib/libnoversion.dylib
usr/lib/libonlyversion.dylib
usr/lib/libonlyversion.1.dylib
usr/lib/libonlysoversion.dylib
usr/lib/libonlysoversion.5.dylib

Loading…
Cancel
Save