diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-03-04 13:09:05 +0530 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-03-04 09:12:51 -0500 |
commit | a24651f33a925c5860a58c3fb8e7b5ec2efbccbd (patch) | |
tree | 01b8f3dedf1ec4147f25ebaa6a110f454918f1ff | |
parent | 2ecb26c9ae093a16c1f79b3b81ca0c66c054f579 (diff) | |
download | meson-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.
-rw-r--r-- | mesonbuild/build.py | 33 | ||||
-rw-r--r-- | test cases/osx/2 library versions/installed_files.txt | 3 |
2 files changed, 23 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 diff --git a/test cases/osx/2 library versions/installed_files.txt b/test cases/osx/2 library versions/installed_files.txt index 4d58502..fc76046 100644 --- a/test cases/osx/2 library versions/installed_files.txt +++ b/test cases/osx/2 library versions/installed_files.txt @@ -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 |