summaryrefslogtreecommitdiff
path: root/tests/scanner
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2019-03-24 19:28:52 +0100
committerChristoph Reiter <reiter.christoph@gmail.com>2019-03-25 19:09:10 +0100
commitfd9125f1e011ca4e87597b4dacdac44c27adc687 (patch)
tree66aafcce47083fbaa3e079316644223895db5dd9 /tests/scanner
parente695a4fec2b44117d0fbe800eae20d7e87e9bcc5 (diff)
downloadgobject-introspection-fd9125f1e011ca4e87597b4dacdac44c27adc687.tar.gz
shlibs: fall back to basename on macOS for relative paths. Fixes #222
On macOS we ideally want to write the final absolute path of the library into the gir and typelib. Up until now we inferred the install path from the .la file in case we used libtool and through otool in case we weren't using libtool hoping that the install_name was matching the install path. meson currently sets the install_name of libraries to "@rpath/foo.dylib" and adds rpaths to the executables in the build dir. Only during install does it change the install_name to the absolute target path in all places. Since we get called during build time we only get the @rpath from otool, which then makes things fail at runtime since the executables don't have the matching rpath set. To make this somewhat work just fall back to the basename for relative paths, so we dlopen "foo.dylib" and depend on things being in /usr/local/lib or DYLD_FALLBACK_LIBRARY_PATH including the lib path (see man dlopen)
Diffstat (limited to 'tests/scanner')
-rw-r--r--tests/scanner/test_shlibs.py31
1 files changed, 26 insertions, 5 deletions
diff --git a/tests/scanner/test_shlibs.py b/tests/scanner/test_shlibs.py
index f3fb0d2e..a8337c60 100644
--- a/tests/scanner/test_shlibs.py
+++ b/tests/scanner/test_shlibs.py
@@ -1,6 +1,8 @@
import unittest
+import sys
+import os
-from giscanner.shlibs import resolve_from_ldd_output
+from giscanner.shlibs import resolve_from_ldd_output, sanitize_shlib_path
class TestLddParser(unittest.TestCase):
@@ -18,6 +20,28 @@ class TestLddParser(unittest.TestCase):
['libglib-2.0.so.0', 'libgtk-3.so.0', 'libpango-1.0.so.0'],
resolve_from_ldd_output(libraries, output))
+ @unittest.skipUnless(os.name == "posix", "posix only")
+ def test_resolve_from_ldd_output_macos_rpath(self):
+ output = '''\
+ @rpath/libbarapp-1.0.dylib (compatibility version 0.0.0, current version 0.0.0)
+ /foo/libgio-2.0.0.dylib (compatibility version 5801.0.0, current version 5801.3.0)
+ /foo/libgmodule-2.0.0.dylib (compatibility version 5801.0.0, current version 5801.3.0)'''
+
+ libraries = ['barapp-1.0']
+ shlibs = resolve_from_ldd_output(libraries, output)
+ self.assertEqual(shlibs, ['@rpath/libbarapp-1.0.dylib'])
+ self.assertEqual(sanitize_shlib_path(shlibs[0]), 'libbarapp-1.0.dylib')
+
+ @unittest.skipUnless(os.name == "posix", "posix only")
+ def test_sanitize_shlib_path(self):
+ self.assertEqual(
+ sanitize_shlib_path('@rpath/libbarapp-1.0.dylib'),
+ 'libbarapp-1.0.dylib')
+
+ self.assertEqual(
+ sanitize_shlib_path('/foo/bar'),
+ '/foo/bar' if sys.platform == 'darwin' else 'bar')
+
def test_unresolved_library(self):
output = ''
libraries = ['foo']
@@ -87,10 +111,7 @@ class TestLddParser(unittest.TestCase):
self.assertEqual(
['/usr/lib/libfoo.so'],
- resolve_from_ldd_output(['foo'], output, basename=False))
- self.assertEqual(
- ['libfoo.so'],
- resolve_from_ldd_output(['foo'], output, basename=True))
+ resolve_from_ldd_output(['foo'], output))
if __name__ == '__main__':