diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/SCons/Tool/__init__.py | 67 | ||||
-rw-r--r-- | src/engine/SCons/Tool/cyglink.py | 32 | ||||
-rw-r--r-- | src/engine/SCons/Tool/gnulink.py | 19 | ||||
-rw-r--r-- | src/engine/SCons/Tool/install.py | 23 |
4 files changed, 83 insertions, 58 deletions
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 4a27c0d..0e6e7d8 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -367,7 +367,7 @@ LdModSuffixGenerator = _LibSuffixGenerator('LdMod') ImpLibSuffixGenerator = _LibSuffixGenerator('ImpLib') class _LibSymlinkGenerator(_LibInfoGeneratorBase): - """Library symlink map generator. It generates a dict of symlinks that + """Library symlink map generator. It generates a list of symlinks that should be created by SharedLibrary or LoadableModule builders""" def __init__(self, libtype): super(_LibSymlinkGenerator, self).__init__(libtype, 'Symlinks') @@ -397,7 +397,7 @@ class _LibSymlinkGenerator(_LibInfoGeneratorBase): Verbose = False if Verbose: - print "_LibSymLinkGenerator: str(libnode)=%r" % str(libnode) + print "_LibSymLinkGenerator: libnode=%r" % libnode.get_path() symlinks = None @@ -412,7 +412,7 @@ class _LibSymlinkGenerator(_LibInfoGeneratorBase): symlinks = self.generate_versioned_lib_info(env, [libnode, version, suffix], **kw) if Verbose: - print '_LibSymlinkGenerator: return symlinks=%r' % symlinks + print '_LibSymlinkGenerator: return symlinks=%r' % StringizeLibSymlinks(symlinks) return symlinks ShLibSymlinkGenerator = _LibSymlinkGenerator('ShLib') @@ -430,7 +430,7 @@ class _LibNameGenerator(_LibInfoGeneratorBase): Verbose = False if Verbose: - print "_LibNameGenerator: str(libnode)=%r" % str(libnode) + print "_LibNameGenerator: libnode=%r" % libnode.get_path() version = self.get_lib_version(env, **kw) if Verbose: @@ -442,7 +442,7 @@ class _LibNameGenerator(_LibInfoGeneratorBase): name = self.generate_versioned_lib_info(env, [libnode, version, suffix], **kw) if not name: - name = os.path.basename(str(libnode)) + name = os.path.basename(libnode.get_path()) if Verbose: print '_LibNameGenerator: return name=%r' % name @@ -464,7 +464,7 @@ class _LibSonameGenerator(_LibInfoGeneratorBase): Verbose = False if Verbose: - print "_LibSonameGenerator: str(libnode)=%r" % str(libnode) + print "_LibSonameGenerator: libnode=%r" % libnode.get_path() soname = env.subst('$SONAME') if not soname: @@ -489,41 +489,56 @@ class _LibSonameGenerator(_LibInfoGeneratorBase): ShLibSonameGenerator = _LibSonameGenerator('ShLib') LdModSonameGenerator = _LibSonameGenerator('LdMod') +def StringizeLibSymlinks(symlinks): + """Converts list with pairs of nodes to list with pairs of node paths + (strings). Used mainly for debugging.""" + if SCons.Util.is_List(symlinks): + try: + return [ (k.get_path(), v.get_path()) for k,v in symlinks ] + except TypeError: + return symlinks + except ValueError: + return symlinks + else: + return symlinks + def EmitLibSymlinks(env, symlinks, libnode): """Used by emitters to handle (shared/versioned) library symlinks""" Verbose = False - for linkname, linktgt in symlinks.iteritems(): - env.SideEffect(linkname, linktgt) + + # nodes involved in process... all symlinks + library + nodes = list(set([ x for x,y in symlinks ] + [libnode])) + + for link, linktgt in symlinks: + env.SideEffect(link, linktgt) if(Verbose): - print "EmitLibSymlinks: SideEffect(", linkname, ", ", linktgt, ")" - clean = list(set(filter(lambda x : x != linktgt, symlinks.keys() + [str(libnode)]))) - env.Clean(linktgt, clean) + print "EmitLibSymlinks: SideEffect(%r,%r)" % (link.get_path(), linktgt.get_path()) + clean_list = filter(lambda x : x != linktgt, nodes) + env.Clean(linktgt, clean_list) if(Verbose): - print "EmitLibSymlinks: Clean(%r,%r)" % (linktgt, clean) + print "EmitLibSymlinks: Clean(%r,%r)" % (linktgt.get_path(), map(lambda x : x.get_path(), clean_list)) def CreateLibSymlinks(env, symlinks): - """Physically creates symlinks. The symlinks argument must be a dict in - form { linkname : linktarget } + """Physically creates symlinks. The symlinks argument must be a list in + form [ (link, linktarget), ... ], where link and linktarget are SCons + nodes. """ Verbose = False - for linkname, linktgt in symlinks.iteritems(): - linkname = str(env.arg2nodes(linkname)[0]) - linkdir = os.path.dirname(linkname) - if linkdir: - # NOTE: os.path.relpath appears in python 2.6 - linktgt = os.path.relpath(linktgt, linkdir) - else: - linktgt = os.path.basename(linktgt) + for link, linktgt in symlinks: + linktgt = link.get_dir().rel_path(linktgt) + link = link.get_path() if(Verbose): - print "CreateLibSymlinks: preparing to add symlink ", linkname, " -> ", linktgt + print "CreateLibSymlinks: preparing to add symlink %r -> %r" % (link, linktgt) try: - os.remove(linkname) + os.remove(link) + if(Verbose): + print "CreateLibSymlinks: removed old file %r" % link except: pass - os.symlink(linktgt, linkname) + os.symlink(linktgt, link) if(Verbose): - print "CreateLibSymlinks: add symlink ", linkname, " -> ", linktgt + print "CreateLibSymlinks: add symlink %r -> %r" % (link, linktgt) return 0 def LibSymlinksActionFunction(target, source, env): diff --git a/src/engine/SCons/Tool/cyglink.py b/src/engine/SCons/Tool/cyglink.py index 4033978..59258b2 100644 --- a/src/engine/SCons/Tool/cyglink.py +++ b/src/engine/SCons/Tool/cyglink.py @@ -56,6 +56,9 @@ def ldmod_generator(target, source, env, for_signature): def _lib_emitter(target, source, env, **kw): Verbose = False + if Verbose: + print "_lib_emitter: target[0]=%r" % target[0].get_path() + try: vp = kw['varprefix'] except KeyError: vp = 'SHLIB' @@ -65,6 +68,9 @@ def _lib_emitter(target, source, env, **kw): dll = env.FindIxes(target, '%sPREFIX' % vp, '%sSUFFIX' % vp) no_import_lib = env.get('no_import_lib', 0) + if Verbose: + print "_lib_emitter: dll=%r" % dll.get_path() + if not dll or len(target) > 1: raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$%sSUFFIX" % vp)) @@ -73,20 +79,28 @@ def _lib_emitter(target, source, env, **kw): if dll.name[len(pre):len(pre)+3] == 'lib': dll.name = pre + dll.name[len(pre)+3:] + if Verbose: + print "_lib_emitter: dll.name=%r" % dll.name + orig_target = target target = [env.fs.File(dll)] target[0].attributes.shared = 1 + if Verbose: + print "_lib_emitter: after target=[env.fs.File(dll)]: target[0]=%r" % target[0].get_path() + # Append an import lib target if not no_import_lib: # Create list of target libraries as strings target_strings = env.ReplaceIxes(orig_target[0], '%sPREFIX' % vp, '%sSUFFIX' % vp, 'IMPLIBPREFIX', 'IMPLIBSUFFIX') + if Verbose: + print "_lib_emitter: target_strings=%r" % target_strings implib_target = env.fs.File(target_strings) if Verbose: - print "_lib_emitter: implib_target=%r" % str(implib_target) + print "_lib_emitter: implib_target=%r" % implib_target.get_path() implib_target.attributes.shared = 1 target.append(implib_target) @@ -94,7 +108,7 @@ def _lib_emitter(target, source, env, **kw): implib_libtype=libtype, generator_libtype=libtype+'ImpLib') if Verbose: - print "_lib_emitter: implib symlinks=%r" % symlinks + print "_lib_emitter: implib symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks) if symlinks: SCons.Tool.EmitLibSymlinks(env, symlinks, implib_target) implib_target.attributes.shliblinks = symlinks @@ -129,20 +143,19 @@ def _versioned_implib_name(env, libnode, version, suffix, **kw): def _versioned_implib_symlinks(env, libnode, version, suffix, **kw): """Generate link names that should be created for a versioned shared lirbrary. - Returns a dictionary in the form { linkname : linktarget } + Returns a list in the form [ (link, linktarget), ... ] """ Verbose = False if Verbose: - print "_versioned_implib_symlinks: str(libnode)=%r" % str(libnode) + print "_versioned_implib_symlinks: libnode=%r" % libnode.get_path() print "_versioned_implib_symlinks: version=%r" % version try: libtype = kw['libtype'] except KeyError: libtype = 'ShLib' - symlinks = {} - linkdir = os.path.dirname(str(libnode)) + linkdir = os.path.dirname(libnode.get_path()) if Verbose: print "_versioned_implib_symlinks: linkdir=%r" % linkdir @@ -154,12 +167,11 @@ def _versioned_implib_symlinks(env, libnode, version, suffix, **kw): major = version.split('.')[0] - link0 = os.path.join(str(linkdir), name) - - symlinks[link0] = str(libnode) + link0 = env.fs.File(os.path.join(linkdir, name)) + symlinks = [(link0, libnode)] if Verbose: - print "_versioned_implib_symlinks: return symlinks=%r" % symlinks + print "_versioned_implib_symlinks: return symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks) return symlinks diff --git a/src/engine/SCons/Tool/gnulink.py b/src/engine/SCons/Tool/gnulink.py index ea0ca5a..14007af 100644 --- a/src/engine/SCons/Tool/gnulink.py +++ b/src/engine/SCons/Tool/gnulink.py @@ -85,18 +85,16 @@ def _versioned_lib_symlinks(env, libnode, version, suffix, name_generator, sonam print "_versioned_lib_symlinks: str(libnode)=%r" % str(libnode) print "_versioned_lib_symlinks: version=%r" % version - symlinks = {} - 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" % symlinks - return symlinks + print "_versioned_lib_symlinks: return symlinks=%r" % None + return None - linkdir = os.path.dirname(str(libnode)) + linkdir = libnode.get_dir() if Verbose: - print "_versioned_lib_symlinks: linkdir=%r" % linkdir + print "_versioned_lib_symlinks: linkdir=%r" % linkdir.get_path() name = name_generator(env, libnode) if Verbose: @@ -104,14 +102,13 @@ def _versioned_lib_symlinks(env, libnode, version, suffix, name_generator, sonam soname = soname_generator(env, libnode) - link0 = os.path.join(str(linkdir), soname) - link1 = os.path.join(str(linkdir), name) + link0 = env.fs.File(soname, linkdir) + link1 = env.fs.File(name, linkdir) - symlinks[link0] = str(libnode) - symlinks[link1] = link0 + symlinks = [ (link0, libnode), (link1, link0) ] if Verbose: - print "_versioned_lib_symlinks: return symlinks=%r" % symlinks + print "_versioned_lib_symlinks: return symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks) return symlinks diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py index c5c2adb..9d5db9f 100644 --- a/src/engine/SCons/Tool/install.py +++ b/src/engine/SCons/Tool/install.py @@ -147,18 +147,19 @@ def copyFuncVersionedLib(dest, source, env): return 0 def listShlibLinksToInstall(dest, source, env): - install_links = {} - install_dir = os.path.dirname(str(dest)) + install_links = [] source = env.arg2nodes(source) + dest = env.fs.File(dest) + install_dir = dest.get_dir() for src in source: - links = getattr(getattr(src,'attributes',None), 'shliblinks', None) - if SCons.Util.is_Dict(links): - for linkname, linktgt in links.iteritems(): - linkname_base = os.path.basename(str(linkname)) - linktgt_base = os.path.basename(str(linktgt)) - install_linkname = os.path.join(install_dir, linkname_base) - install_linktgt = os.path.join(install_dir, linktgt_base) - install_links[install_linkname] = install_linktgt + symlinks = getattr(getattr(src,'attributes',None), 'shliblinks', None) + if symlinks: + for link, linktgt in symlinks: + link_base = os.path.basename(link.get_path()) + linktgt_base = os.path.basename(linktgt.get_path()) + install_link = env.fs.File(link_base, install_dir) + install_linktgt = env.fs.File(linktgt_base, install_dir) + install_links.append((install_link, install_linktgt)) return install_links def installShlibLinks(dest, source, env): @@ -167,7 +168,7 @@ def installShlibLinks(dest, source, env): symlinks = listShlibLinksToInstall(dest, source, env) if Verbose: - print 'installShlibLinks: symlinks=%r' % symlinks + print 'installShlibLinks: symlinks=%r' % SCons.Tool.StringizeLibSymlinks(symlinks) if symlinks: SCons.Tool.CreateLibSymlinks(env, symlinks) return |