Allow soname to be an arbitrary string and fix symlink generation.

pull/1102/head
Jussi Pakkanen 8 years ago
parent d651727208
commit 07d7e87411
  1. 11
      mesonbuild/backend/ninjabackend.py
  2. 6
      mesonbuild/build.py
  3. 9
      run_unittests.py
  4. 8
      test cases/unit/1 soname/CMakeLists.txt
  5. 18
      test cases/unit/1 soname/meson.build

@ -2004,14 +2004,21 @@ rule FORTRAN_DEP_HACK
def generate_shlib_aliases(self, target, outdir):
basename = target.get_filename()
aliases = target.get_aliaslist()
for alias in aliases:
for i, alias in enumerate(aliases):
aliasfile = os.path.join(self.environment.get_build_dir(), outdir, alias)
try:
os.remove(aliasfile)
except Exception:
pass
# If both soversion and version are set and to different values,
# the .so symlink must point to the soversion symlink rather than the
# original file.
if i == 0 and len(aliases) > 1:
pointed_to_filename = aliases[1]
else:
pointed_to_filename = basename
try:
os.symlink(basename, aliasfile)
os.symlink(pointed_to_filename, aliasfile)
except NotImplementedError:
mlog.debug("Library versioning disabled because symlinks are not supported.")
except OSError:

@ -1070,12 +1070,10 @@ class SharedLibrary(BuildTarget):
self.soversion = str(self.soversion)
if not isinstance(self.soversion, str):
raise InvalidArguments('Shared library soversion is not a string or integer.')
try:
int(self.soversion)
except ValueError:
raise InvalidArguments('Shared library soversion must be a valid integer')
elif self.ltversion:
# library version is defined, get the soversion from that
# We replicate what Autotools does here and take the first
# number of the version by default.
self.soversion = self.ltversion.split('.')[0]
# Visual Studio module-definitions file
if 'vs_module_defs' in kwargs:

@ -215,8 +215,7 @@ class LinuxlikeTests(unittest.TestCase):
def test_soname(self):
testdir = os.path.join(self.unit_test_dir, '1 soname')
subprocess.check_call(['cmake', '-DCMAKE_BUILD_TYPE=debug', '-G', 'Ninja', testdir],
cwd=self.builddir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
self.init(testdir)
self.build()
# File without aliases set.
@ -229,9 +228,9 @@ class LinuxlikeTests(unittest.TestCase):
# File with version set
verset = os.path.join(self.builddir, 'libverset.so')
self.assertTrue(os.path.exists(verset + '.4.5.6'))
self.assertEqual(os.readlink(verset), 'libverset.so.4.5.6')
self.assertEqual(self.get_soname(verset), 'libverset.so.4.5.6')
self.assertEqual(len(glob(verset[:-3] + '*')), 2)
self.assertEqual(os.readlink(verset), 'libverset.so.4')
self.assertEqual(self.get_soname(verset), 'libverset.so.4')
self.assertEqual(len(glob(verset[:-3] + '*')), 3)
# File with soversion set
soverset = os.path.join(self.builddir, 'libsoverset.so')

@ -1,3 +1,11 @@
# This is a CMake version of this test. It behaves slightly differently
# so in case you ever need to debug this, here it is.
#
# The biggest difference is that if SOVERSION is not set, it
# is set to VERSION. Autotools sets it to the first number
# of VERSION. That is, for version number 1.2.3 CMake sets
# soname to 1.2.3 but Autotools sets it to 1.
project(vertest C)
cmake_minimum_required(VERSION 3.5)

@ -0,0 +1,18 @@
project('vertest', 'c')
shared_library('nover', 'versioned.c')
shared_library('verset', 'versioned.c',
version : '4.5.6')
shared_library('soverset', 'versioned.c',
soversion : '1.2.3')
shared_library('bothset', 'versioned.c',
soversion : '1.2.3',
version : '4.5.6')
shared_library('settosame', 'versioned.c',
soversion : '7.8.9',
version : '7.8.9')
Loading…
Cancel
Save