diff options
author | Pawel Tomulik <ptomulik@meil.pw.edu.pl> | 2015-09-20 00:24:11 (GMT) |
---|---|---|
committer | Pawel Tomulik <ptomulik@meil.pw.edu.pl> | 2015-09-20 00:24:11 (GMT) |
commit | 9a43408e4419ba54733222df65a38a9d1a925b6d (patch) | |
tree | ea497274eac796008c26ee7f1db144195f63f40d /src | |
parent | f6f919842bf5dc265422309b98546e182e3ee9ae (diff) | |
download | SCons-9a43408e4419ba54733222df65a38a9d1a925b6d.zip SCons-9a43408e4419ba54733222df65a38a9d1a925b6d.tar.gz SCons-9a43408e4419ba54733222df65a38a9d1a925b6d.tar.bz2 |
support for versioned libraries for sunlink
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/SCons/Tool/gnulink.py | 96 | ||||
-rw-r--r-- | src/engine/SCons/Tool/link.py | 85 | ||||
-rw-r--r-- | src/engine/SCons/Tool/sunlink.py | 21 |
3 files changed, 112 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 |