aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2021-11-24 17:29:06 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2021-11-24 23:18:53 +0530
commitaf5993fffd37944a15326cb9510775b269352ce0 (patch)
tree7783fbd8d21a98a70497a9b3e35bffcc85b43b07 /unittests
parentbd9d9818711eaba18b774e17c9ce405c5020c6f9 (diff)
downloadmeson-af5993fffd37944a15326cb9510775b269352ce0.zip
meson-af5993fffd37944a15326cb9510775b269352ce0.tar.gz
meson-af5993fffd37944a15326cb9510775b269352ce0.tar.bz2
shared_module: Add soname when used as a link target
Emit a detailed deprecation warning that explains what to do instead. Also add a unittest. ``` DEPRECATION: target prog links against shared module mymod, which is incorrect. This will be an error in the future, so please use shared_library() for mymod instead. If shared_module() was used for mymod because it has references to undefined symbols, use shared_libary() with `override_options: ['b_lundef=false']` instead. ``` Fixes https://github.com/mesonbuild/meson/issues/9492
Diffstat (limited to 'unittests')
-rw-r--r--unittests/allplatformstests.py6
-rw-r--r--unittests/linuxliketests.py18
2 files changed, 22 insertions, 2 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 03992bd..30c0572 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -1946,8 +1946,10 @@ class AllPlatformTests(BasePlatformTests):
"""
tdir = os.path.join(self.unit_test_dir, '30 shared_mod linking')
out = self.init(tdir)
- msg = ('WARNING: target links against shared modules. This is not '
- 'recommended as it is not supported on some platforms')
+ msg = ('''DEPRECATION: target prog links against shared module mymod, which is incorrect.
+ This will be an error in the future, so please use shared_library() for mymod instead.
+ If shared_module() was used for mymod because it has references to undefined symbols,
+ use shared_libary() with `override_options: ['b_lundef=false']` instead.''')
self.assertIn(msg, out)
def test_mixed_language_linker_check(self):
diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py
index 0f99f01..8ff0f8e 100644
--- a/unittests/linuxliketests.py
+++ b/unittests/linuxliketests.py
@@ -438,6 +438,24 @@ class LinuxlikeTests(BasePlatformTests):
self.assertEqual(get_soname(bothset), 'libbothset.so.1.2.3')
self.assertEqual(len(self.glob_sofiles_without_privdir(bothset[:-3] + '*')), 3)
+ # A shared_module that is not linked to anything
+ module = os.path.join(libpath, 'libsome_module.so')
+ self.assertPathExists(module)
+ self.assertFalse(os.path.islink(module))
+ self.assertEqual(get_soname(module), None)
+
+ # A shared_module that is not linked to an executable with link_with:
+ module = os.path.join(libpath, 'liblinked_module1.so')
+ self.assertPathExists(module)
+ self.assertFalse(os.path.islink(module))
+ self.assertEqual(get_soname(module), 'liblinked_module1.so')
+
+ # A shared_module that is not linked to an executable with dependencies:
+ module = os.path.join(libpath, 'liblinked_module2.so')
+ self.assertPathExists(module)
+ self.assertFalse(os.path.islink(module))
+ self.assertEqual(get_soname(module), 'liblinked_module2.so')
+
def test_soname(self):
self._test_soname_impl(self.builddir, False)