diff options
author | Dirk Baechle <dl9obn@darc.de> | 2014-12-19 14:59:20 (GMT) |
---|---|---|
committer | Dirk Baechle <dl9obn@darc.de> | 2014-12-19 14:59:20 (GMT) |
commit | a759567a12fbd11989bea5f8eb0238639ec15e8b (patch) | |
tree | bd3e106ab9d2a4022e4f6cb6cfe5fbdc15f0d79a /src/engine | |
parent | f0121389aa88ab9a3d232f5e516850d2aad2bf00 (diff) | |
download | SCons-a759567a12fbd11989bea5f8eb0238639ec15e8b.zip SCons-a759567a12fbd11989bea5f8eb0238639ec15e8b.tar.gz SCons-a759567a12fbd11989bea5f8eb0238639ec15e8b.tar.bz2 |
- switching versioned shared libs to using Node.attributes
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/SCons/Tool/__init__.py | 19 | ||||
-rw-r--r-- | src/engine/SCons/Tool/install.py | 20 | ||||
-rw-r--r-- | src/engine/SCons/Tool/link.py | 32 |
3 files changed, 53 insertions, 18 deletions
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index c6da57d..0447dd9 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -293,7 +293,10 @@ symlinks for the platform we are on""" version = None # libname includes the version number if one was given - libname = target[0].name + if hasattr(target[0].attributes, 'shlibname'): + libname = target[0].attributes.shlibname + else: + libname = target[0].name platform = env.subst('$PLATFORM') shlib_suffix = env.subst('$SHLIBSUFFIX') shlink_flags = SCons.Util.CLVar(env.subst('$SHLINKFLAGS')) @@ -340,12 +343,22 @@ symlinks for the platform we are on""" if version: # here we need the full pathname so the links end up in the right directory - libname = target[0].path + if hasattr(target[0].attributes, 'shlibname'): + libname = target[0].attributes.shlibname + else: + libname = target[0].path + if Verbose: + print "VerShLib: target lib is = ", libname + print "VerShLib: name is = ", target[0].name + print "VerShLib: dir is = ", target[0].dir.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 + if hasattr(target[0].attributes, 'shlibname'): + lib_ver = target[0].attributes.shlibname + else: + lib_ver = target[0].name # make symlink of adjacent names in linknames for count in range(len(linknames)): linkname = linknames[count] diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py index 66869b7..9f2e937 100644 --- a/src/engine/SCons/Tool/install.py +++ b/src/engine/SCons/Tool/install.py @@ -145,15 +145,19 @@ def copyFuncVersionedLib(dest, source, env): return 0 -def versionedLibVersion(dest, env): +def versionedLibVersion(dest, source, env): """Check if dest is a version shared library name. Return version, libname, & install_dir if it is.""" Verbose = False platform = env.subst('$PLATFORM') if not (platform == 'posix' or platform == 'darwin' or platform == 'sunos'): return (None, None, None) - libname = os.path.basename(dest) - install_dir = os.path.dirname(dest) + if (hasattr(source[0], 'attributes') and + hasattr(source[0].attributes, 'shlibname')): + libname = source[0].attributes.shlibname + else: + libname = os.path.basename(str(dest)) + install_dir = os.path.dirname(str(dest)) shlib_suffix = env.subst('$SHLIBSUFFIX') # See if the source name is a versioned shared library, get the version number result = False @@ -196,7 +200,7 @@ def versionedLibLinks(dest, source, env): """If we are installing a versioned shared library create the required links.""" Verbose = False linknames = [] - version, libname, install_dir = versionedLibVersion(dest, env) + version, libname, install_dir = versionedLibVersion(dest, source, env) if version != None: # libname includes the version number if one was given @@ -258,7 +262,11 @@ def installFuncVersionedLib(target, source, env): assert len(target)==len(source), \ "Installing source %s into target %s: target and source lists must have same length."%(list(map(str, source)), list(map(str, target))) for t,s in zip(target,source): - if install(t.get_path(),s.get_path(),env): + if hasattr(t.attributes, 'shlibname'): + tpath = os.path.join(t.get_dir(), t.attributes.shlibname) + else: + tpath = t.get_path() + if install(tpath,s.get_path(),env): return 1 return 0 @@ -301,7 +309,7 @@ def add_versioned_targets_to_INSTALLED_FILES(target, source, env): print "ver lib emitter ",repr(target) # see if we have a versioned shared library, if so generate side effects - version, libname, install_dir = versionedLibVersion(target[0].path, env) + version, libname, install_dir = versionedLibVersion(target[0], source, env) if version != None: # generate list of link names linknames = SCons.Tool.VersionShLibLinkNames(version,libname,env) diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py index f70f5b8..2624946 100644 --- a/src/engine/SCons/Tool/link.py +++ b/src/engine/SCons/Tool/link.py @@ -82,13 +82,18 @@ def shlib_emitter(target, source, env): version = env.subst('$SHLIBVERSION') if version: version_names = shlib_emitter_names(target, source, env) - # change the name of the target to include the version number - target[0].name = version_names[0] - for name in version_names: - env.SideEffect(name, target[0]) - env.Clean(target[0], name) + # mark the target with the shared libraries name, including + # the version number + target[0].attributes.shlibname = version_names[0] + shlib = env.File(version_names[0], directory=target[0].get_dir()) + target[0].attributes.shlibpath = shlib.path + for name in version_names[1:]: + env.SideEffect(name, shlib) + env.Clean(shlib, name) if Verbose: print "shlib_emitter: add side effect - ",name + env.Clean(shlib, target[0]) + return ([shlib], source) except KeyError: version = None return (target, source) @@ -107,9 +112,12 @@ def shlib_emitter_names(target, source, env): if version: if platform == 'posix' or platform == 'sunos': versionparts = version.split('.') - name = target[0].name + if hasattr(target[0].attributes, 'shlibname'): + name = target[0].attributes.shlibname + else: + name = target[0].name # generate library name with the version number - version_name = target[0].name + '.' + version + version_name = name + '.' + version if Verbose: print "shlib_emitter_names: target is ", version_name print "shlib_emitter_names: side effect: ", name @@ -125,7 +133,10 @@ def shlib_emitter_names(target, source, env): version_names.append(name) elif platform == 'darwin': shlib_suffix = env.subst('$SHLIBSUFFIX') - name = target[0].name + if hasattr(target[0].attributes, 'shlibname'): + name = target[0].attributes.shlibname + else: + name = target[0].name # generate library name with the version number suffix_re = re.escape(shlib_suffix) version_name = re.sub(suffix_re, '.' + version + shlib_suffix, name) @@ -136,7 +147,10 @@ def shlib_emitter_names(target, source, env): version_names.append(version_name) elif platform == 'cygwin': shlib_suffix = env.subst('$SHLIBSUFFIX') - name = target[0].name + if hasattr(target[0].attributes, 'shlibname'): + name = target[0].attributes.shlibname + else: + name = target[0].name # generate library name with the version number suffix_re = re.escape(shlib_suffix) version_name = re.sub(suffix_re, '-' + re.sub('\.', '-', version) + shlib_suffix, name) |