aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-06-08 00:50:39 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-06-18 06:33:23 +0000
commit96b7fdb723e5a8d2d7143c7c7a6abc433e0b3da0 (patch)
tree04bcc0057f228675f1c0c183a0927754bab40c23 /run_unittests.py
parent69f817b0e36f8fba7d2bd81cf569d9ad09bb7a2b (diff)
downloadmeson-96b7fdb723e5a8d2d7143c7c7a6abc433e0b3da0.zip
meson-96b7fdb723e5a8d2d7143c7c7a6abc433e0b3da0.tar.gz
meson-96b7fdb723e5a8d2d7143c7c7a6abc433e0b3da0.tar.bz2
macos: Rewrite install_name for dependent built libraries on install
On macOS, we set the install_name for built libraries to @rpath/libfoo.dylib, and when linking to the library, we set the RPATH to its path in the build directory. This allows all built binaries to be run as-is from the build directory (uninstalled). However, on install, we have to strip all the RPATHs because they point to the build directory, and we change the install_name of all built libraries to the absolute path to the library. This causes the install name in binaries to be out of date. We now change that install name to point to the absolute path to each built library after installation. Fixes https://github.com/mesonbuild/meson/issues/3038 Fixes https://github.com/mesonbuild/meson/issues/3077 With this, the default workflow on macOS matches what everyone seems to do, including Autotools and CMake. The next step is providing a way for build files to override the install_name that is used after installation for use with, f.ex., private libraries when combined with the install_rpath: kwarg on targets.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/run_unittests.py b/run_unittests.py
index c4d9547..1c722c1 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -2759,7 +2759,8 @@ class LinuxlikeTests(BasePlatformTests):
self._test_soname_impl(self.builddir, False)
def test_installed_soname(self):
- self._test_soname_impl(self.installdir + self.libdir, True)
+ libdir = self.installdir + os.path.join(self.prefix, self.libdir)
+ self._test_soname_impl(libdir, True)
def test_compiler_check_flags_order(self):
'''
@@ -3333,33 +3334,45 @@ endian = 'little'
self.run_tests()
@skipIfNoPkgconfig
- def test_uninstalled_usage_external_library(self):
+ def test_usage_external_library(self):
'''
Test that uninstalled usage of an external library (from the system or
- PkgConfigDependency) works. On Linux/BSD/macOS it tests if RPATHs are
- set correctly.
-
- TODO: On Windows, this can test whether PATH is set properly
+ PkgConfigDependency) works. On macOS, this workflow works out of the
+ box. On Linux, BSDs, Windows, etc, you need to set extra arguments such
+ as LD_LIBRARY_PATH, etc, so this test is skipped.
The system library is found with cc.find_library() and pkg-config deps.
'''
+ if not is_osx():
+ raise unittest.SkipTest('workflow currently only works on macOS')
oldprefix = self.prefix
# Install external library so we can find it
testdir = os.path.join(self.unit_test_dir, '33 external, internal library rpath', 'external library')
+ # install into installdir without using DESTDIR
installdir = self.installdir
self.prefix = installdir
self.init(testdir)
+ self.prefix = oldprefix
self.build()
self.install(use_destdir=False)
- self.prefix = oldprefix
# New builddir for the consumer
self.new_builddir()
os.environ['LIBRARY_PATH'] = os.path.join(installdir, self.libdir)
os.environ['PKG_CONFIG_PATH'] = os.path.join(installdir, self.libdir, 'pkgconfig')
testdir = os.path.join(self.unit_test_dir, '33 external, internal library rpath', 'built library')
+ # install into installdir without using DESTDIR
+ self.prefix = self.installdir
self.init(testdir)
+ self.prefix = oldprefix
self.build()
+ # test uninstalled
self.run_tests()
+ # test running after installation
+ self.install(use_destdir=False)
+ prog = os.path.join(self.installdir, 'bin', 'prog')
+ self._run([prog])
+ out = self._run(['otool', '-L', prog])
+ self.assertNotIn('@rpath', out)
class LinuxArmCrossCompileTests(BasePlatformTests):