summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2016-05-12 14:48:46 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2016-05-12 14:48:46 (GMT)
commit170105963ce92f49eeb7441739b921198dec0505 (patch)
tree65c2fd825aac0682392b60f767c88c3b02603e0f /src
parentef93655b57fcd93cfda0e21439f5fc60df161238 (diff)
downloadSCons-170105963ce92f49eeb7441739b921198dec0505.zip
SCons-170105963ce92f49eeb7441739b921198dec0505.tar.gz
SCons-170105963ce92f49eeb7441739b921198dec0505.tar.bz2
copy src/engine/SCons/Tool/__init__.py as the merge had issues at some point in the past the the versioned shared library logic got mangled. Then 2to3 that file. Seems to e working now
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Tool/__init__.py175
1 files changed, 43 insertions, 132 deletions
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index 26caf2f..4cd242b 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -34,7 +34,6 @@ tool definition.
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-from __future__ import print_function
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
@@ -53,6 +52,7 @@ import SCons.Scanner.D
import SCons.Scanner.LaTeX
import SCons.Scanner.Prog
import SCons.Scanner.SWIG
+import collections
DefaultToolpath=[]
@@ -122,7 +122,7 @@ class Tool(object):
if file:
file.close()
except ImportError as e:
- if not str(e).startswith ("No module"):
+ if str(e)!="No module named %s"%self.name:
raise SCons.Errors.EnvironmentError(e)
try:
import zipimport
@@ -152,7 +152,7 @@ class Tool(object):
file.close()
return module
except ImportError as e:
- if not str(e).startswith("No module"):
+ if str(e)!="No module named %s"%self.name:
raise SCons.Errors.EnvironmentError(e)
try:
import zipimport
@@ -244,9 +244,6 @@ def createStaticLibBuilder(env):
return static_lib
-# used by the following two methods
-linknames = []
-
def _call_linker_cb(env, callback, args, result = None):
"""Returns the result of env['LINKCALLBACKS'][callback](*args)
if env['LINKCALLBACKS'] is a dictionary and env['LINKCALLBACKS'][callback]
@@ -258,109 +255,22 @@ def _call_linker_cb(env, callback, args, result = None):
Verbose = False
if Verbose:
- print('_call_linker_cb: args={:r}'.format(args))
- print('_call_linker_cb: callback={:r}'.format(callback))
-
+ print('_call_linker_cb: args=%r' % args)
+ print('_call_linker_cb: callback=%r' % callback)
+
try:
cbfun = env['LINKCALLBACKS'][callback]
except (KeyError, TypeError):
if Verbose:
- print('_call_linker_cb: env["LINKCALLBACKS"][{:r}] not found or can not be used'.format(callback))
+ print('_call_linker_cb: env["LINKCALLBACKS"][%r] not found or can not be used' % callback)
pass
else:
if Verbose:
- print('_call_linker_cb: env["LINKCALLBACKS"][{:r}] found'.format(callback))
- print('_call_linker_cb: env["LINKCALLBACKS"][{:r}]={:r}'.format(callback, cbfun))
- if (callable(cbfun)):
- if Verbose:
- print("VersionShLibLinkNames: linkname ",linkname, ", target ",libname)
- linknames.append(linkname)
- # note: no Windows case here (win32 or cygwin);
- # MSVC doesn't support this type of versioned shared libs.
- # (could probably do something for MinGW though)
- return linknames
-
-def VersionedSharedLibrary(target = None, source= None, env=None):
- """Build a shared library. If the environment has SHLIBVERSION
-defined make a versioned shared library and create the appropriate
-symlinks for the platform we are on"""
- Verbose = False
- try:
- version = env.subst('$SHLIBVERSION')
- except KeyError:
- version = None
-
- # libname includes the version number if one was given
- libname = target[0].name
- platform = env.subst('$PLATFORM')
- shlib_suffix = env.subst('$SHLIBSUFFIX')
- shlink_flags = SCons.Util.CLVar(env.subst('$SHLINKFLAGS'))
- if Verbose:
- print("VersionShLib: libname = ",libname)
- print("VersionShLib: platform = ",platform)
- print("VersionShLib: shlib_suffix = ",shlib_suffix)
- print("VersionShLib: target = ",str(target[0]))
-
- if version:
- # set the shared library link flags
- if platform == 'posix':
- shlink_flags += [ '-Wl,-Bsymbolic' ]
- # OpenBSD doesn't usually use SONAME for libraries
- if not sys.platform.startswith('openbsd'):
- # continue setup of shlink flags for all other POSIX systems
- suffix_re = re.escape(shlib_suffix + '.' + version)
- (major, age, revision) = version.split(".")
- # soname will have only the major version number in it
- soname = re.sub(suffix_re, shlib_suffix, libname) + '.' + major
- shlink_flags += [ '-Wl,-soname=%s' % soname ]
- if Verbose:
- print(" soname ",soname,", shlink_flags ",shlink_flags)
- elif platform == 'cygwin':
- shlink_flags += [ '-Wl,-Bsymbolic',
- '-Wl,--out-implib,${TARGET.base}.a' ]
- elif platform == 'darwin':
- shlink_flags += [ '-current_version', '%s' % version,
- '-compatibility_version', '%s' % version,
- '-undefined', 'dynamic_lookup' ]
- if Verbose:
- print("VersionShLib: shlink_flags = ",shlink_flags)
- envlink = env.Clone()
- envlink['SHLINKFLAGS'] = shlink_flags
- else:
- envlink = env
-
- result = SCons.Defaults.ShLinkAction(target, source, envlink)
-
- if version:
- # here we need the full pathname so the links end up in the right directory
- libname = target[0].path
- linknames = VersionShLibLinkNames(version, libname, env)
- if Verbose:
- print("VerShLib: linknames ",linknames)
- # Here we just need the file name w/o path as the target of the link
- lib_ver = target[0].name
- # make symlink of adjacent names in linknames
- for count in range(len(linknames)):
- linkname = linknames[count]
- if count > 0:
- try:
- os.remove(lastlinkname)
- except:
- pass
- os.symlink(os.path.basename(linkname),lastlinkname)
- if Verbose:
- print("VerShLib: made sym link of %s -> %s" % (lastlinkname,linkname))
- lastlinkname = linkname
- # finish chain of sym links with link to the actual library
- if len(linknames)>0:
- try:
- os.remove(lastlinkname)
- except:
- pass
- os.symlink(lib_ver,lastlinkname)
+ print('_call_linker_cb: env["LINKCALLBACKS"][%r] found' % callback)
+ print('_call_linker_cb: env["LINKCALLBACKS"][%r]=%r' % (callback, cbfun))
+ if(isinstance(cbfun, collections.Callable)):
if Verbose:
- print("VerShLib: made sym link of %s -> %s" % (linkname, lib_ver))
- print('_call_linker_cb: env["LINKCALLBACKS"][{:r}] is callable'.format(callback))
+ print('_call_linker_cb: env["LINKCALLBACKS"][%r] is callable' % callback)
result = cbfun(env, *args)
return result
@@ -479,7 +389,7 @@ class _LibInfoGeneratorBase(object):
def generate_versioned_lib_info(self, env, args, result = None, **kw):
callback = self.get_versioned_lib_info_generator(**kw)
- return _call_linker_cb(env, callback, args, result)
+ return _call_linker_cb(env, callback, args, result)
class _LibPrefixGenerator(_LibInfoGeneratorBase):
"""Library prefix generator, used as target_prefix in SharedLibrary and
@@ -498,17 +408,17 @@ class _LibPrefixGenerator(_LibInfoGeneratorBase):
prefix = self.get_lib_prefix(env,**kw2)
if Verbose:
- print("_LibPrefixGenerator: input prefix={:r}".format(prefix))
+ print("_LibPrefixGenerator: input prefix=%r" % prefix)
version = self.get_lib_version(env, **kw2)
if Verbose:
- print("_LibPrefixGenerator: version={:r}".format(version))
+ print("_LibPrefixGenerator: version=%r" % version)
if version:
prefix = self.generate_versioned_lib_info(env, [prefix, version], prefix, **kw2)
if Verbose:
- print("_LibPrefixGenerator: return prefix={:r}".format(prefix))
+ print("_LibPrefixGenerator: return prefix=%r" % prefix)
return prefix
ShLibPrefixGenerator = _LibPrefixGenerator('ShLib')
@@ -532,17 +442,17 @@ class _LibSuffixGenerator(_LibInfoGeneratorBase):
suffix = self.get_lib_suffix(env, **kw2)
if Verbose:
- print("_LibSuffixGenerator: input suffix={:r}".format(suffix))
+ print("_LibSuffixGenerator: input suffix=%r" % suffix)
version = self.get_lib_version(env, **kw2)
if Verbose:
- print("_LibSuffixGenerator: version={:r}".format(version))
+ print("_LibSuffixGenerator: version=%r" % version)
if version:
suffix = self.generate_versioned_lib_info(env, [suffix, version], suffix, **kw2)
if Verbose:
- print("_LibSuffixGenerator: return suffix={:r}".format(suffix))
+ print("_LibSuffixGenerator: return suffix=%r" % suffix)
return suffix
ShLibSuffixGenerator = _LibSuffixGenerator('ShLib')
@@ -565,15 +475,15 @@ class _LibSymlinkGenerator(_LibInfoGeneratorBase):
kw2 = kw
if Verbose:
- print("_LibSymLinkGenerator: libnode={:r}".format(libnode.get_path()))
+ print("_LibSymLinkGenerator: libnode=%r" % libnode.get_path())
symlinks = None
version = self.get_lib_version(env, **kw2)
disable = self.get_lib_noversionsymlinks(env, **kw2)
if Verbose:
- print('_LibSymlinkGenerator: version={:r}'.format(version))
- print('_LibSymlinkGenerator: disable={:r}'.format(disable))
+ print('_LibSymlinkGenerator: version=%r' % version)
+ print('_LibSymlinkGenerator: disable=%r' % disable)
if version and not disable:
prefix = self.get_lib_prefix(env,**kw2)
@@ -581,7 +491,7 @@ class _LibSymlinkGenerator(_LibInfoGeneratorBase):
symlinks = self.generate_versioned_lib_info(env, [libnode, version, prefix, suffix], **kw2)
if Verbose:
- print('_LibSymlinkGenerator: return symlinks={:r}'.format(StringizeLibSymlinks(symlinks)))
+ print('_LibSymlinkGenerator: return symlinks=%r' % StringizeLibSymlinks(symlinks))
return symlinks
ShLibSymlinkGenerator = _LibSymlinkGenerator('ShLib')
@@ -590,7 +500,7 @@ ImpLibSymlinkGenerator = _LibSymlinkGenerator('ImpLib')
class _LibNameGenerator(_LibInfoGeneratorBase):
"""Generates "unmangled" library name from a library file node.
-
+
Generally, it's thought to revert modifications done by prefix/suffix
generators (_LibPrefixGenerator/_LibSuffixGenerator) used by a library
builder. For example, on gnulink the suffix generator used by SharedLibrary
@@ -600,7 +510,7 @@ class _LibNameGenerator(_LibInfoGeneratorBase):
"$SHLIBSUFFIX" in the node's basename. So that, if $SHLIBSUFFIX is ".so",
$SHLIBVERSION is "0.1.2" and the node path is "/foo/bar/libfoo.so.0.1.2",
the _LibNameGenerator shall return "libfoo.so". Other link tools may
- implement it's own way of library name unmangling.
+ implement it's own way of library name unmangling.
"""
def __init__(self, libtype):
super(_LibNameGenerator, self).__init__(libtype, 'Name')
@@ -616,11 +526,11 @@ class _LibNameGenerator(_LibInfoGeneratorBase):
kw2 = kw
if Verbose:
- print("_LibNameGenerator: libnode={:r}".format(libnode.get_path()))
+ print("_LibNameGenerator: libnode=%r" % libnode.get_path())
version = self.get_lib_version(env, **kw2)
if Verbose:
- print('_LibNameGenerator: version={:r}'.format(version))
+ print('_LibNameGenerator: version=%r' % version)
name = None
if version:
@@ -632,7 +542,7 @@ class _LibNameGenerator(_LibInfoGeneratorBase):
name = os.path.basename(libnode.get_path())
if Verbose:
- print('_LibNameGenerator: return name={:r}'.format(name))
+ print('_LibNameGenerator: return name=%r' % name)
return name
@@ -641,7 +551,7 @@ LdModNameGenerator = _LibNameGenerator('LdMod')
ImpLibNameGenerator = _LibNameGenerator('ImpLib')
class _LibSonameGenerator(_LibInfoGeneratorBase):
- """Library soname generator. Returns library soname (e.g. libfoo.so.0) for
+ """Library soname generator. Returns library soname (e.g. libfoo.so.0) for
a given node (e.g. /foo/bar/libfoo.so.0.1.2)"""
def __init__(self, libtype):
super(_LibSonameGenerator, self).__init__(libtype, 'Soname')
@@ -657,13 +567,13 @@ class _LibSonameGenerator(_LibInfoGeneratorBase):
kw2 = kw
if Verbose:
- print("_LibSonameGenerator: libnode={:r}".format(libnode.get_path()))
+ print("_LibSonameGenerator: libnode=%r" % libnode.get_path())
soname = _call_env_subst(env, '$SONAME', **kw2)
if not soname:
version = self.get_lib_version(env,**kw2)
if Verbose:
- print("_LibSonameGenerator: version={:r}".format(version))
+ print("_LibSonameGenerator: version=%r" % version)
if version:
prefix = self.get_lib_prefix(env,**kw2)
suffix = self.get_lib_suffix(env,**kw2)
@@ -673,10 +583,10 @@ class _LibSonameGenerator(_LibInfoGeneratorBase):
# fallback to library name (as returned by appropriate _LibNameGenerator)
soname = _LibNameGenerator(self.get_libtype())(env, libnode)
if Verbose:
- print("_LibSonameGenerator: FALLBACK: soname={:r}".format(soname))
+ print("_LibSonameGenerator: FALLBACK: soname=%r" % soname)
if Verbose:
- print("_LibSonameGenerator: return soname={:r}".format(soname))
+ print("_LibSonameGenerator: return soname=%r" % soname)
return soname
@@ -704,39 +614,39 @@ def EmitLibSymlinks(env, symlinks, libnode, **kw):
clean_targets = kw.get('clean_targets', [])
if not SCons.Util.is_List(clean_targets):
clean_targets = [ clean_targets ]
-
+
for link, linktgt in symlinks:
env.SideEffect(link, linktgt)
if(Verbose):
- print("EmitLibSymlinks: SideEffect({:r},{:r})".format(link.get_path(), linktgt.get_path()))
- clean_list = filter(lambda x : x != linktgt, nodes)
+ print("EmitLibSymlinks: SideEffect(%r,%r)" % (link.get_path(), linktgt.get_path()))
+ clean_list = [x for x in nodes if x != linktgt]
env.Clean(list(set([linktgt] + clean_targets)), clean_list)
if(Verbose):
- print("EmitLibSymlinks: Clean({:r},{:r})".format(linktgt.get_path(), map(lambda x : x.get_path(), clean_list)))
+ print("EmitLibSymlinks: Clean(%r,%r)" % (linktgt.get_path(), [x.get_path() for x in clean_list]))
def CreateLibSymlinks(env, symlinks):
"""Physically creates symlinks. The symlinks argument must be a list in
form [ (link, linktarget), ... ], where link and linktarget are SCons
nodes.
"""
-
+
Verbose = False
for link, linktgt in symlinks:
linktgt = link.get_dir().rel_path(linktgt)
link = link.get_path()
if(Verbose):
- print("CreateLibSymlinks: preparing to add symlink {:r} -> {:r}".format(link, linktgt))
+ print("CreateLibSymlinks: preparing to add symlink %r -> %r" % (link, linktgt))
# Delete the (previously created) symlink if exists. Let only symlinks
# to be deleted to prevent accidental deletion of source files...
if env.fs.islink(link):
env.fs.unlink(link)
if(Verbose):
- print("CreateLibSymlinks: removed old symlink {:r}".format(link))
+ print("CreateLibSymlinks: removed old symlink %r" % link)
# If a file or directory exists with the same name as link, an OSError
# will be thrown, which should be enough, I think.
env.fs.symlink(linktgt, link)
if(Verbose):
- print("CreateLibSymlinks: add symlink {:r} -> {:r}".format(link, linktgt))
+ print("CreateLibSymlinks: add symlink %r -> %r" % (link, linktgt))
return 0
def LibSymlinksActionFunction(target, source, env):
@@ -761,7 +671,7 @@ def LibSymlinksStrFun(target, source, env, *args):
else:
cmd += ": %s" % linkstr
return cmd
-
+
LibSymlinksAction = SCons.Action.Action(LibSymlinksActionFunction, LibSymlinksStrFun)
@@ -1040,7 +950,7 @@ class ToolInitializer(object):
so we no longer copy and re-bind them when the construction
environment gets cloned.
"""
- for method in self.methods.values():
+ for method in list(self.methods.values()):
env.RemoveMethod(method)
def apply_tools(self, env):
@@ -1228,3 +1138,4 @@ def tool_list(platform, env):
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
+