Commit ce51dc12 authored by Marcel Huber's avatar Marcel Huber
Browse files

fixed package creation in regards to installing dependant libs to packagedir

parent 838f2094
......@@ -194,3 +194,51 @@ class Win32Finder(LibFinder):
def getSystemLibDirs(self, env):
return os.environ['PATH'].split(os.pathsep)
try:
from SCons.Tool import EmitLibSymlinks
except:
import SCons.Util
# copied over from scons 2.4.1
def EmitLibSymlinks(env, symlinks, libnode, **kw):
"""Used by emitters to handle (shared/versioned) library symlinks"""
nodes = list(set([ x for x,_ in symlinks ] + [libnode]))
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)
clean_list = filter(lambda x : x != linktgt, nodes)
env.Clean(list(set([linktgt] + clean_targets)), clean_list)
# consolidated copy of SCons.Tool.VersionShLibLinkNames
# and SCons.Tool.install.versionedLibVersion as of scons 2.3.6
# adapted to accept non-patch versions too
def versionedLibVersion(dest, source, env):
if (hasattr(source[0], 'attributes') and
hasattr(source[0].attributes, 'shlibname')):
libname = source[0].attributes.shlibname
else:
libname = os.path.basename(str(dest))
shlib_suffix = env.subst('$SHLIBSUFFIX')
version_pattern = r'(?P<version>(?P<major>[0-9]+)\.(?P<minor>[0-9]+)(\.?(?P<patch>[0-9a-zA-Z]+))?)'
version = None
versioned_re = re.compile(r'(?P<libname>.*)(?P<suffix>' + re.escape(shlib_suffix) + r')\.' + version_pattern)
result = versioned_re.search(libname)
linknames = []
if result:
version = result.group('version')
if version and version.count(".") >= 1:
# For libfoo.so.x.y.z, linknames libfoo.so libfoo.so.x.y libfoo.so.x
# First linkname has no version number
linkname = result.group('libname')+result.group('suffix')
linknames.append(linkname)
major_name = linkname + "." + result.group('major')
for linkname in [major_name, ]:
linknames.append(linkname)
return (version, linknames)
......@@ -14,12 +14,13 @@ Tool to collect system libraries needed by an executable/shared library
# -------------------------------------------------------------------------
import os
import re
import threading
from logging import getLogger
from SCons.Errors import UserError
from SCons.Node.Alias import default_ans
from SConsider.LibFinder import FinderFactory
from SCons.Tool import install as inst_tool, VersionShLibLinkNames
from SConsider.LibFinder import FinderFactory, EmitLibSymlinks, versionedLibVersion
from SCons.Tool import install as inst_tool
logger = getLogger(__name__)
# needs locking because it is manipulated during multi-threaded build phase
......@@ -28,14 +29,6 @@ systemLibTargetsRLock = threading.RLock()
aliasPrefix = '__SystemLibs_'
def versionedLibVersion(dest, source, env):
# handle interface change for scons >=2.3.6
try:
return inst_tool.versionedLibVersion(dest, source, env)
except TypeError:
return inst_tool.versionedLibVersion(dest.path, env)
def notInDir(env, directory, path):
return not env.File(path).is_under(directory)
......@@ -69,11 +62,11 @@ def real_lib_path(env, target):
node = env.File(os.path.realpath(node.get_abspath()))
return node
def installSystemLibs(source):
"""This function is called during the build phase and adds targets
dynamically to the dependency tree."""
from SConsider.PackageRegistry import PackageRegistry
from SCons.Defaults import SharedObjectEmitter
sourcenode = PackageRegistry().getRealTarget(source)
if not sourcenode:
return None
......@@ -89,12 +82,7 @@ def installSystemLibs(source):
source_syslibs = []
def install_node_to_destdir(targets_list, node, install_path, fn=env.Install):
from stat import S_IRUSR, S_IRGRP, S_IROTH, S_IXUSR
from SCons.Defaults import Chmod
# ensure executable flag on installed shared libs
mode = S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR
target = fn(dir=install_path, source=node)
env.AddPostAction(target, Chmod(str(target[0]), mode))
targets_list[node.name] = target
return target
......@@ -105,6 +93,9 @@ def installSystemLibs(source):
install_dir = env.makeInstallablePathFromDir(ownlibDir)
for libnode in deplibs:
real_libnode = real_lib_path(env, libnode)
# tag file node as shared library
real_libnode, _ = SharedObjectEmitter([real_libnode],None,None)
real_libnode = real_libnode[0]
node_name = real_libnode.name
target = []
if node_name in systemLibTargets:
......@@ -112,14 +103,15 @@ def installSystemLibs(source):
else:
# figure out if we deal with a versioned shared library
# otherwise we need to fall back to Install builder and Symlink
version, libname, _ = versionedLibVersion(real_libnode, source, env)
linknames = []
version, linknames = versionedLibVersion(real_libnode, source, env)
if version:
symlinks = map(lambda n: (env.fs.File(n, install_dir), real_libnode), linknames)
EmitLibSymlinks(env, symlinks, real_libnode)
real_libnode.attributes.shliblinks = symlinks
target = install_node_to_destdir(systemLibTargets,
real_libnode,
install_dir,
fn=env.InstallVersionedLib)
linknames = VersionShLibLinkNames(version, libname, env)
else:
target = install_node_to_destdir(systemLibTargets, real_libnode, install_dir)
if not node_name == libnode.name:
......@@ -171,11 +163,8 @@ def generate(env, *args, **kw):
node_name_short = real_libnode.name
if node_name_short not in systemLibTargets:
if real_libnode.is_under(ownlibDir):
version, libname, _ = versionedLibVersion(real_libnode, source, env)
linknames = []
if version:
linknames = VersionShLibLinkNames(version, libname, env)
else:
version, linknames = versionedLibVersion(real_libnode, source, env)
if not version:
libname = os.path.basename(libpath)
if not libname == real_libnode.name:
linknames.append(libname)
......
......@@ -19,11 +19,10 @@ downgrade.
import os
import re
import platform
import shutil
import stat
from logging import getLogger
import SCons.Action
import SCons.Builder
from SConsider.LibFinder import EmitLibSymlinks, versionedLibVersion
logger = getLogger(__name__)
......@@ -139,7 +138,7 @@ def findLibrary(env, basedir, libname, dir_has_to_match=True, strict_lib_name_ma
libVersion = env.get('buildSettings', {}).get('libVersion', '')
# FIXME: libVersion on win
if libVersion:
sharedLibs = [entry for entry in sharedLibs if entry['libVersion'] == libVersion]
sharedLibs = [entry for entry in sharedLibs if entry['libVersion'].startswith(libVersion)]
if preferStaticLib:
allLibs = staticLibs + sharedLibs
......@@ -212,6 +211,12 @@ def precompLibNamesEmitter(target, source, env):
target.append(SCons.Script.Dir('.').File(srcfile))
else:
installedTarget = libraryVariantDir.File(srcfile)
version, linknames = versionedLibVersion(sourcenode, source, env)
if version:
symlinks = map(lambda n: (env.fs.File(n, libraryVariantDir), installedTarget), linknames)
EmitLibSymlinks(env, symlinks, installedTarget)
sourcenode.attributes.shliblinks = symlinks
target.append(installedTarget)
return (target, newsource)
......@@ -235,6 +240,8 @@ def prePackageCollection(env, **_):
def generate(env):
from SConsider.Callback import Callback
from SCons.Tool import install
import SCons.Defaults
SymbolicLinkAction = SCons.Action.Action(createSymLink,
"Generating symbolic link for '$SOURCE' as '$TARGET'")
SymbolicLinkBuilder = SCons.Builder.Builder(
......@@ -243,11 +250,14 @@ def generate(env):
)
env.Append(BUILDERS={"Symlink": SymbolicLinkBuilder})
PrecompLibAction = SCons.Action.Action(install.installVerLib_action,
def wrapPrecompLibAction(target, source, env):
return install.installVerLib_action(target, source, env)
PrecompLibAction = SCons.Action.Action(wrapPrecompLibAction,
"Installing precompiled library '$SOURCE' as '$TARGET'")
PrecompLibBuilder = SCons.Builder.Builder(
action=[PrecompLibAction],
emitter=[precompLibNamesEmitter, install.add_versioned_targets_to_INSTALLED_FILES],
emitter=[precompLibNamesEmitter, SCons.Defaults.SharedObjectEmitter, install.add_versioned_targets_to_INSTALLED_FILES],
multi=0,
source_factory=env.fs.Entry,
single_source=True)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment