diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-09-17 21:48:41 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-10-08 07:34:39 -0400 |
commit | 4dc798dc7e878f082746c900a9bf0e7c31fe738f (patch) | |
tree | cbe1bc854a6d69563cc2c1f2babb9fd1eb4ec2f9 | |
parent | 9fdec2d23f5209148da6279d8b3893dfbc682af3 (diff) | |
download | meson-4dc798dc7e878f082746c900a9bf0e7c31fe738f.zip meson-4dc798dc7e878f082746c900a9bf0e7c31fe738f.tar.gz meson-4dc798dc7e878f082746c900a9bf0e7c31fe738f.tar.bz2 |
Check that soname matches the filename. Closes #785.
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 3 | ||||
-rw-r--r-- | mesonbuild/compilers.py | 2 | ||||
-rwxr-xr-x | munit.py | 31 |
3 files changed, 29 insertions, 7 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 6b6b4ea..f2600cf 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1827,7 +1827,8 @@ rule FORTRAN_DEP_HACK soversion = target.soversion else: soversion = None - commands += linker.get_soname_args(target.name, abspath, soversion) + soname = target.prefix + target.name + '.' + target.suffix + commands += linker.get_soname_args(soname, abspath, soversion) # This is only visited when using the Visual Studio toolchain if target.vs_module_defs and hasattr(linker, 'gen_vs_module_defs_args'): commands += linker.gen_vs_module_defs_args(target.vs_module_defs.rel_to_builddir(self.build_to_src)) diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index c81a599..d92d509 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -1894,7 +1894,7 @@ def get_gcc_soname_args(gcc_type, shlib_name, path, soversion): sostr = '.' + soversion if gcc_type == GCC_STANDARD or gcc_type == GCC_MINGW: # Might not be correct for mingw but seems to work. - return ['-Wl,-soname,lib%s.so%s' % (shlib_name, sostr)] + return ['-Wl,-soname,%s%s' % (shlib_name, sostr)] elif gcc_type == GCC_OSX: return ['-install_name', os.path.join(path, 'lib' + shlib_name + '.dylib')] else: @@ -15,26 +15,47 @@ import unittest, os, shutil import subprocess +import re + +def get_soname(fname): + # HACK, fix to not use shell. + raw_out = subprocess.check_output(['readelf', '-a', fname]) + pattern = re.compile(b'soname: \[(.*?)\]') + for line in raw_out.split(b'\n'): + m = pattern.search(line) + if m is not None: + return m.group(1) class LinuxlikeTests(unittest.TestCase): def setUp(self): super().setUp() src_root = os.path.split(__file__)[0] + self.builddir = 'unittestdir' # fixme to be unique self.meson_command = [os.path.join(src_root, 'meson.py')] - self.ninja_command = ['ninja'] + self.ninja_command = ['ninja', '-C', self.builddir] self.common_test_dir = os.path.join(src_root, 'test cases/common') - self.builddir = 'unittestdir' # fixme to be unique os.mkdir(self.builddir) def tearDown(self): shutil.rmtree(self.builddir) super().tearDown() - def test_simple(self): - testdir = os.path.join(self.common_test_dir, '1 trivial') + def test_basic_soname(self): + testdir = os.path.join(self.common_test_dir, '4 shared') + subprocess.check_call(self.meson_command + [testdir, self.builddir]) + subprocess.check_call(self.ninja_command) + lib1 = os.path.join(self.builddir, 'libmylib.so') + soname = get_soname(lib1) + self.assertEqual(soname, b'libmylib.so') + + def test_custom_soname(self): + testdir = os.path.join(self.common_test_dir, '27 library versions') subprocess.check_call(self.meson_command + [testdir, self.builddir]) - subprocess.check_call(self.ninja_command, cwd=self.builddir) + subprocess.check_call(self.ninja_command) + lib1 = os.path.join(self.builddir, 'prefixsomelib.suffix') + soname = get_soname(lib1) + self.assertEqual(soname, b'prefixsomelib.suffix') if __name__ == '__main__': unittest.main() |