summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/engine/SCons/Tool/gnulink.py96
-rw-r--r--src/engine/SCons/Tool/link.py85
-rw-r--r--src/engine/SCons/Tool/sunlink.py21
-rw-r--r--test/LINK/VersionedLib-VariantDir.py8
-rw-r--r--test/LINK/VersionedLib-j2.py8
-rw-r--r--test/LINK/VersionedLib-subdir.py8
-rw-r--r--test/LINK/VersionedLib.py14
7 files changed, 150 insertions, 90 deletions
diff --git a/src/engine/SCons/Tool/gnulink.py b/src/engine/SCons/Tool/gnulink.py
index aabc2f1..92c38c4 100644
--- a/src/engine/SCons/Tool/gnulink.py
+++ b/src/engine/SCons/Tool/gnulink.py
@@ -41,90 +41,6 @@ import re
import link
-def _versioned_lib_suffix(env, suffix, version):
- """For suffix='.so' and version='0.1.2' it returns '.so.0.1.2'"""
- Verbose = False
- if Verbose:
- print "_versioned_lib_suffix: suffix=%r" % suffix
- print "_versioned_lib_suffix: version=%r" % version
- if not suffix.endswith(version):
- suffix = suffix + '.' + version
- if Verbose:
- print "_versioned_lib_suffix: return suffix=%r" % suffix
- return suffix
-
-def _versioned_lib_soname(env, libnode, version, prefix, suffix, name_func):
- """For libnode='/optional/dir/libfoo.so.X.Y.Z' it returns 'libfoo.so.X'"""
- Verbose = False
- if Verbose:
- print "_versioned_lib_soname: version=%r" % version
- name = name_func(env, libnode, version, prefix, suffix)
- if Verbose:
- print "_versioned_lib_soname: name=%r" % name
- major = version.split('.')[0]
- soname = name + '.' + major
- if Verbose:
- print "_versioned_lib_soname: soname=%r" % soname
- return soname
-
-def _versioned_shlib_soname(env, libnode, version, prefix, suffix):
- return _versioned_lib_soname(env, libnode, version, prefix, suffix, link._versioned_shlib_name)
-
-def _versioned_ldmod_soname(env, libnode, version, prefix, suffix):
- return _versioned_lib_soname(env, libnode, version, prefix, suffix, link._versioned_ldmod_name)
-
-def _versioned_lib_symlinks(env, libnode, version, prefix, suffix, name_func, soname_func):
- """Generate link names that should be created for a versioned shared lirbrary.
- Returns a dictionary in the form { linkname : linktarget }
- """
- Verbose = False
-
- if Verbose:
- print "_versioned_lib_symlinks: libnode=%r" % libnode.get_path()
- print "_versioned_lib_symlinks: version=%r" % version
-
- if sys.platform.startswith('openbsd'):
- # OpenBSD uses x.y shared library versioning numbering convention
- # and doesn't use symlinks to backwards-compatible libraries
- if Verbose:
- print "_versioned_lib_symlinks: return symlinks=%r" % None
- return None
-
- linkdir = libnode.get_dir()
- if Verbose:
- print "_versioned_lib_symlinks: linkdir=%r" % linkdir.get_path()
-
- name = name_func(env, libnode, version, prefix, suffix)
- if Verbose:
- print "_versioned_lib_symlinks: name=%r" % name
-
- soname = soname_func(env, libnode, version, prefix, suffix)
-
- link0 = env.fs.File(soname, linkdir)
- link1 = env.fs.File(name, linkdir)
-
- # We create direct symlinks, not daisy-chained.
- if link0 == libnode:
- # This enables SHLIBVERSION without periods (e.g. SHLIBVERSION=1)
- symlinks = [ (link1, libnode) ]
- else:
- # This handles usual SHLIBVERSION, i.e. '1.2', '1.2.3', etc.
- symlinks = [ (link0, libnode), (link1, libnode) ]
-
- if Verbose:
- print "_versioned_lib_symlinks: return symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks)
-
- return symlinks
-
-def _versioned_shlib_symlinks(env, libnode, version, prefix, suffix):
- nf = link._versioned_shlib_name
- sf = _versioned_shlib_soname
- return _versioned_lib_symlinks(env, libnode, version, prefix, suffix, nf, sf)
-
-def _versioned_ldmod_symlinks(env, libnode, version, prefix, suffix):
- nf = link._versioned_ldmod_name
- sf = _versioned_ldmod_soname
- return _versioned_lib_symlinks(env, libnode, version, prefix, suffix, nf, sf)
def generate(env):
"""Add Builders and construction variables for gnulink to an Environment."""
@@ -160,14 +76,14 @@ def generate(env):
env['LdModSonameGenerator'] = SCons.Tool.LdModSonameGenerator
env['LINKCALLBACKS'] = {
- 'VersionedShLibSuffix' : _versioned_lib_suffix,
- 'VersionedLdModSuffix' : _versioned_lib_suffix,
- 'VersionedShLibSymlinks' : _versioned_shlib_symlinks,
- 'VersionedLdModSymlinks' : _versioned_ldmod_symlinks,
+ 'VersionedShLibSuffix' : link._versioned_lib_suffix,
+ 'VersionedLdModSuffix' : link._versioned_lib_suffix,
+ 'VersionedShLibSymlinks' : link._versioned_shlib_symlinks,
+ 'VersionedLdModSymlinks' : link._versioned_ldmod_symlinks,
'VersionedShLibName' : link._versioned_shlib_name,
'VersionedLdModName' : link._versioned_ldmod_name,
- 'VersionedShLibSoname' : _versioned_shlib_soname,
- 'VersionedLdModSoname' : _versioned_shlib_soname,
+ 'VersionedShLibSoname' : link._versioned_shlib_soname,
+ 'VersionedLdModSoname' : link._versioned_shlib_soname,
}
def exists(env):
diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py
index d52a9e5..0af7776 100644
--- a/src/engine/SCons/Tool/link.py
+++ b/src/engine/SCons/Tool/link.py
@@ -142,6 +142,91 @@ def _versioned_ldmod_name(env, libnode, version, prefix, suffix, **kw):
sg = SCons.Tool.LdModSuffixGenerator
return _versioned_lib_name(env, libnode, version, prefix, suffix, pg, sg, **kw)
+def _versioned_lib_suffix(env, suffix, version):
+ """For suffix='.so' and version='0.1.2' it returns '.so.0.1.2'"""
+ Verbose = False
+ if Verbose:
+ print "_versioned_lib_suffix: suffix=%r" % suffix
+ print "_versioned_lib_suffix: version=%r" % version
+ if not suffix.endswith(version):
+ suffix = suffix + '.' + version
+ if Verbose:
+ print "_versioned_lib_suffix: return suffix=%r" % suffix
+ return suffix
+
+def _versioned_lib_soname(env, libnode, version, prefix, suffix, name_func):
+ """For libnode='/optional/dir/libfoo.so.X.Y.Z' it returns 'libfoo.so.X'"""
+ Verbose = False
+ if Verbose:
+ print "_versioned_lib_soname: version=%r" % version
+ name = name_func(env, libnode, version, prefix, suffix)
+ if Verbose:
+ print "_versioned_lib_soname: name=%r" % name
+ major = version.split('.')[0]
+ soname = name + '.' + major
+ if Verbose:
+ print "_versioned_lib_soname: soname=%r" % soname
+ return soname
+
+def _versioned_shlib_soname(env, libnode, version, prefix, suffix):
+ return _versioned_lib_soname(env, libnode, version, prefix, suffix, _versioned_shlib_name)
+
+def _versioned_ldmod_soname(env, libnode, version, prefix, suffix):
+ return _versioned_lib_soname(env, libnode, version, prefix, suffix, _versioned_ldmod_name)
+
+def _versioned_lib_symlinks(env, libnode, version, prefix, suffix, name_func, soname_func):
+ """Generate link names that should be created for a versioned shared lirbrary.
+ Returns a dictionary in the form { linkname : linktarget }
+ """
+ Verbose = False
+
+ if Verbose:
+ print "_versioned_lib_symlinks: libnode=%r" % libnode.get_path()
+ print "_versioned_lib_symlinks: version=%r" % version
+
+ if sys.platform.startswith('openbsd'):
+ # OpenBSD uses x.y shared library versioning numbering convention
+ # and doesn't use symlinks to backwards-compatible libraries
+ if Verbose:
+ print "_versioned_lib_symlinks: return symlinks=%r" % None
+ return None
+
+ linkdir = libnode.get_dir()
+ if Verbose:
+ print "_versioned_lib_symlinks: linkdir=%r" % linkdir.get_path()
+
+ name = name_func(env, libnode, version, prefix, suffix)
+ if Verbose:
+ print "_versioned_lib_symlinks: name=%r" % name
+
+ soname = soname_func(env, libnode, version, prefix, suffix)
+
+ link0 = env.fs.File(soname, linkdir)
+ link1 = env.fs.File(name, linkdir)
+
+ # We create direct symlinks, not daisy-chained.
+ if link0 == libnode:
+ # This enables SHLIBVERSION without periods (e.g. SHLIBVERSION=1)
+ symlinks = [ (link1, libnode) ]
+ else:
+ # This handles usual SHLIBVERSION, i.e. '1.2', '1.2.3', etc.
+ symlinks = [ (link0, libnode), (link1, libnode) ]
+
+ if Verbose:
+ print "_versioned_lib_symlinks: return symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks)
+
+ return symlinks
+
+def _versioned_shlib_symlinks(env, libnode, version, prefix, suffix):
+ nf = _versioned_shlib_name
+ sf = _versioned_shlib_soname
+ return _versioned_lib_symlinks(env, libnode, version, prefix, suffix, nf, sf)
+
+def _versioned_ldmod_symlinks(env, libnode, version, prefix, suffix):
+ nf = _versioned_ldmod_name
+ sf = _versioned_ldmod_soname
+ return _versioned_lib_symlinks(env, libnode, version, prefix, suffix, nf, sf)
+
def generate(env):
"""Add Builders and construction variables for gnulink to an Environment."""
diff --git a/src/engine/SCons/Tool/sunlink.py b/src/engine/SCons/Tool/sunlink.py
index 5996a30..c9bb17d 100644
--- a/src/engine/SCons/Tool/sunlink.py
+++ b/src/engine/SCons/Tool/sunlink.py
@@ -66,6 +66,27 @@ def generate(env):
env['RPATHSUFFIX'] = ''
env['_RPATH'] = '${_concat(RPATHPREFIX, RPATH, RPATHSUFFIX, __env__)}'
+ # Support for versioned libraries
+ env['_SHLIBVERSIONFLAGS'] = '$SHLIBVERSIONFLAGS -h $_SHLINKSONAME'
+ env['_LDMODULEVERSIONFLAGS'] = '$LDMODULEVERSIONFLAGS -h $_LDMODULESONAME'
+
+ env['_SHLINKSONAME'] = '${ShLibSonameGenerator(__env__,TARGET)}'
+ env['_LDMODULESONAME'] = '${LdModSonameGenerator(__env__,TARGET)}'
+
+ env['ShLibSonameGenerator'] = SCons.Tool.ShLibSonameGenerator
+ env['LdModSonameGenerator'] = SCons.Tool.LdModSonameGenerator
+
+ env['LINKCALLBACKS'] = {
+ 'VersionedShLibSuffix' : link._versioned_lib_suffix,
+ 'VersionedLdModSuffix' : link._versioned_lib_suffix,
+ 'VersionedShLibSymlinks' : link._versioned_shlib_symlinks,
+ 'VersionedLdModSymlinks' : link._versioned_ldmod_symlinks,
+ 'VersionedShLibName' : link._versioned_shlib_name,
+ 'VersionedLdModName' : link._versioned_ldmod_name,
+ 'VersionedShLibSoname' : link._versioned_shlib_soname,
+ 'VersionedLdModSoname' : link._versioned_shlib_soname,
+ }
+
def exists(env):
return ccLinker
diff --git a/test/LINK/VersionedLib-VariantDir.py b/test/LINK/VersionedLib-VariantDir.py
index a3ea660..7406a33 100644
--- a/test/LINK/VersionedLib-VariantDir.py
+++ b/test/LINK/VersionedLib-VariantDir.py
@@ -126,6 +126,14 @@ elif platform == 'win32':
'foo.lib',
]
obj = 'foo.obj'
+elif platform == 'sunos':
+ # All (?) the files we expect will get created in the current directory
+ files = [
+ 'libfoo.so',
+ 'libfoo.so.0',
+ 'libfoo.so.0.1.2',
+ ]
+ obj = 'so_foo.os'
else:
# All (?) the files we expect will get created in the current directory
files= [
diff --git a/test/LINK/VersionedLib-j2.py b/test/LINK/VersionedLib-j2.py
index 076a4dd..6f37e54 100644
--- a/test/LINK/VersionedLib-j2.py
+++ b/test/LINK/VersionedLib-j2.py
@@ -113,6 +113,14 @@ elif platform == 'win32':
'foo.lib',
'foo.obj',
]
+elif platform == 'sunos':
+ # All (?) the files we expect will get created in the current directory
+ files = [
+ 'libfoo.so',
+ 'libfoo.so.0',
+ 'libfoo.so.0.1.2',
+ 'so_foo.os',
+ ]
else:
# All (?) the files we expect will get created in the current directory
files= [
diff --git a/test/LINK/VersionedLib-subdir.py b/test/LINK/VersionedLib-subdir.py
index 6facd41..15369ef 100644
--- a/test/LINK/VersionedLib-subdir.py
+++ b/test/LINK/VersionedLib-subdir.py
@@ -120,6 +120,14 @@ elif platform == 'win32':
'foo.lib',
]
obj = 'foo.obj'
+elif platform == 'sunos':
+ # All (?) the files we expect will get created in the current directory
+ files = [
+ 'libfoo.so',
+ 'libfoo.so.0',
+ 'libfoo.so.0.1.2',
+ ]
+ obj = 'so_foo.os'
else:
# All (?) the files we expect will get created in the current directory
files= [
diff --git a/test/LINK/VersionedLib.py b/test/LINK/VersionedLib.py
index c68dd55..a75e4a5 100644
--- a/test/LINK/VersionedLib.py
+++ b/test/LINK/VersionedLib.py
@@ -130,6 +130,20 @@ elif platform == 'win32':
'test.dll',
'test.lib',
]
+elif platform == 'sunos':
+ # All (?) the files we expect will get created in the current directory
+ files = [
+ 'libtest.so',
+ 'libtest.so.2',
+ 'libtest.so.2.5.4',
+ 'so_test.os',
+ ]
+ # All (?) the files we expect will get created in the 'installtest' directory
+ instfiles = [
+ 'libtest.so',
+ 'libtest.so.2',
+ 'libtest.so.2.5.4',
+ ]
else:
# All (?) the files we expect will get created in the current directory
files= [