summaryrefslogtreecommitdiffstats
path: root/test/LINK
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2018-12-06 23:25:26 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2018-12-06 23:25:26 (GMT)
commita0aad5a43bb631a97dd45cf1a3899f88adb25ed7 (patch)
treee3d53c07c697e2e456257eb246d197c5bd51564c /test/LINK
parentd620a79ebd590c5864656bd4bbca043e99809454 (diff)
downloadSCons-a0aad5a43bb631a97dd45cf1a3899f88adb25ed7.zip
SCons-a0aad5a43bb631a97dd45cf1a3899f88adb25ed7.tar.gz
SCons-a0aad5a43bb631a97dd45cf1a3899f88adb25ed7.tar.bz2
Fix GH issue #3241 - Support -compatability_version and -current_version flags propagating to linker for shared libraries. Derive them from SHLIBVERSION if not independantly specified
Diffstat (limited to 'test/LINK')
-rw-r--r--test/LINK/applelink.py48
-rw-r--r--test/LINK/applelink_image/SConstruct_CurVers_CompatVers23
2 files changed, 69 insertions, 2 deletions
diff --git a/test/LINK/applelink.py b/test/LINK/applelink.py
index 36b4bf2..b548390 100644
--- a/test/LINK/applelink.py
+++ b/test/LINK/applelink.py
@@ -29,15 +29,59 @@ import os
import TestSCons
_python_ = TestSCons._python_
-_exe = TestSCons._exe
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
-
+test.verbose_set(1)
# Test issue # 2580
test.dir_fixture('applelink_image')
test.run(arguments='-f SConstruct_gh2580 -Q -n', stdout='gcc -o foo.o -c -Fframeworks foo.c\n')
+# Now test combinations of SHLIBVERSION, APPLELINK_CURRENT_VERSION, APPLELINK_COMPATIBILITY_VERSION
+
+
+for SHLIBVERSION, APPLELINK_CURRENT_VERSION, APPLELINK_COMPATIBILITY_VERSION, should_error in [
+ ('1.2.3', '', '', False),
+ ('1.2.3', '9.9.9', '9.9.0', False),
+ ('99999.2.3', '', '', 'AppleLinkInvalidCurrentVersionException'),
+ ('1.2.3', '9.9.999', '9.9.0', 'AppleLinkInvalidCurrentVersionException'),
+ ('1.2.3', '9.9.9', '9.999.0', 'AppleLinkInvalidCompatibilityVersionException'),
+ ('1.2.3', '9.9.9', '99999.99.0', 'AppleLinkInvalidCompatibilityVersionException'),
+]:
+ if not APPLELINK_CURRENT_VERSION:
+ APPLELINK_CURRENT_VERSION = SHLIBVERSION
+ if not APPLELINK_COMPATIBILITY_VERSION:
+ APPLELINK_COMPATIBILITY_VERSION = '.'.join(APPLELINK_CURRENT_VERSION.split('.', 2)[:2] + ['0'])
+
+ if not should_error:
+ expected_stdout = r"^.+ -dynamiclib -Wl,-current_version,{APPLELINK_CURRENT_VERSION} -Wl,-compatibility_version,{APPLELINK_COMPATIBILITY_VERSION}.+".format(
+ **locals())
+ expected_stderr = None
+ expected_status = 0
+ else:
+ expected_stdout = None
+ expected_stderr = r"^.+{should_error}.+".format(**locals())
+ expected_status = 2
+
+ test.run(
+ arguments='-f SConstruct_CurVers_CompatVers SHLIBVERSION={SHLIBVERSION} APPLELINK_CURRENT_VERSION={APPLELINK_CURRENT_VERSION} APPLELINK_COMPATIBILITY_VERSION={APPLELINK_COMPATIBILITY_VERSION}'.format(**locals()),
+ stdout=expected_stdout,
+ stderr=expected_stderr,
+ match=TestSCons.match_re_dotall,
+ status=expected_status)
+
+ if not should_error:
+ # Now run otool -L to get the compat and current version info and verify it's correct in the library.
+ # We expect output such as this
+ # libfoo.1.2.3.dylib:
+ # > libfoo.1.2.3.dylib (compatibility version 1.1.99, current version 9.9.9)
+ # > /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
+ otool_output = "libfoo.{SHLIBVERSION}.dylib:\n\tlibfoo.{SHLIBVERSION}.dylib (compatibility version {APPLELINK_COMPATIBILITY_VERSION}, current version {APPLELINK_CURRENT_VERSION})\n\t/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)\n".format(
+ **locals())
+
+ test.run(program='/usr/bin/otool', arguments='-L libfoo.%s.dylib' % SHLIBVERSION, stdout=otool_output)
+
test.pass_test()
# Local Variables:
diff --git a/test/LINK/applelink_image/SConstruct_CurVers_CompatVers b/test/LINK/applelink_image/SConstruct_CurVers_CompatVers
new file mode 100644
index 0000000..b699ad8
--- /dev/null
+++ b/test/LINK/applelink_image/SConstruct_CurVers_CompatVers
@@ -0,0 +1,23 @@
+
+
+vars = Variables(None, ARGUMENTS)
+vars.Add('SHLIBVERSION', 'Set the SHLIBVERSION', 0)
+vars.Add('APPLELINK_CURRENT_VERSION', 'Set APPLELINK_CURRENT_VERSION', 0)
+vars.Add('APPLELINK_COMPATIBILITY_VERSION', 'Set APPLELINK_COMPATIBILITY_VERSION', 0)
+
+env = Environment(variables = vars, tools=['gcc', 'applelink'])
+
+obj = env.SharedObject('foo.c')
+
+# sl = env.SharedLibrary('foo', obj)
+
+sl = env.SharedLibrary('foo', obj)
+lm = env.LoadableModule('fool', obj)
+
+env.InstallVersionedLib(target='#/install',
+ source=sl)
+
+env.InstallVersionedLib(target='#/install',
+ source=lm)
+
+print("SHLIBVERSION=%s"%env['SHLIBVERSION'])