summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobert Managan <ramanagan@att.net>2012-10-06 04:49:04 (GMT)
committerRobert Managan <ramanagan@att.net>2012-10-06 04:49:04 (GMT)
commit37e7a11197c611b23d1c09711cb55e38651f9798 (patch)
tree31c2aee5c7827e34cf5debb27976ce11ccb28fd8 /src
parenta75755810b08c4d1f6bf7e28211f4a62872b35d8 (diff)
downloadSCons-37e7a11197c611b23d1c09711cb55e38651f9798.zip
SCons-37e7a11197c611b23d1c09711cb55e38651f9798.tar.gz
SCons-37e7a11197c611b23d1c09711cb55e38651f9798.tar.bz2
Add the versioned sh lib and install methods to Environment
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Environment.py74
-rw-r--r--src/engine/SCons/Script/__init__.py1
2 files changed, 75 insertions, 0 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 2c71e61..9a7a848 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -2247,6 +2247,80 @@ class Base(SubstitutionEnvironment):
install._UNIQUE_INSTALLED_FILES = SCons.Util.uniquer_hashables(install._INSTALLED_FILES)
return install._UNIQUE_INSTALLED_FILES
+ def VersionedSharedLibrary(self, libname, version, lib_objs=[],parse_flags=[]):
+ platform = self.subst('$PLATFORM')
+ shlib_pre_action = None
+ shlib_suffix = self.subst('$SHLIBSUFFIX')
+ shlib_post_action = None
+ shlink_flags = SCons.Util.CLVar(self.subst('$SHLINKFLAGS'))
+
+ if platform == 'posix':
+ ilib_suffix = shlib_suffix + '.' + version
+ (major, age, revision) = version.split(".")
+ soname = "lib" + libname + shlib_suffix + "." + major
+ shlink_flags += [ '-Wl,-Bsymbolic', '-Wl,-soname=%s' % soname ]
+ elif platform == 'cygwin':
+ ilib_suffix = shlib_suffix
+ shlink_flags += [ '-Wl,-Bsymbolic',
+ '-Wl,--out-implib,${TARGET.base}.a' ]
+ elif platform == 'darwin':
+ ilib_suffix = '.' + version + shlib_suffix
+ shlink_flags += [ '-current_version', '%s' % version,
+ '-compatibility_version', '%s' % version,
+ '-undefined', 'dynamic_lookup' ]
+
+ ilib = self.SharedLibrary(libname,lib_objs,
+ SHLIBSUFFIX=ilib_suffix,
+ SHLINKFLAGS=shlink_flags,
+ parse_flags=parse_flags)
+
+ if platform == 'darwin':
+ if version.count(".") != 2:
+ # We need a library name in libfoo.x.y.z.dylib form to proceed
+ raise ValueError
+ lib = 'lib' + libname + '.' + version + '.dylib'
+ lib_no_ver = 'lib' + libname + '.dylib'
+ # Link libfoo.x.y.z.dylib to libfoo.dylib
+ self.AddPostAction(ilib, 'rm -f %s; ln -s %s %s' % (
+ lib_no_ver, lib, lib_no_ver))
+ self.Clean(lib, lib_no_ver)
+ elif platform == 'posix':
+ if version.count(".") != 2:
+ # We need a library name in libfoo.so.x.y.z form to proceed
+ raise ValueError
+ lib = "lib" + libname + ".so." + version
+ suffix_re = '%s\\.[0-9\\.]*$' % re.escape(shlib_suffix)
+ # For libfoo.so.x.y.z, links libfoo.so libfoo.so.x.y libfoo.so.x
+ major_name = shlib_suffix + "." + lib.split(".")[2]
+ minor_name = major_name + "." + lib.split(".")[3]
+ for linksuffix in [shlib_suffix, major_name, minor_name]:
+ linkname = re.sub(suffix_re, linksuffix, lib)
+ self.AddPostAction(ilib, 'rm -f %s; ln -s %s %s' % (
+ linkname, lib, linkname))
+ self.Clean(lib, linkname)
+
+ return ilib
+
+ def VersionedSharedLibraryInstall(self, destination, libs):
+ platform = self.subst('$PLATFORM')
+ shlib_suffix = self.subst('$SHLIBSUFFIX')
+ ilibs = self.Install(destination, libs)
+ if platform == 'posix':
+ suffix_re = '%s\\.[0-9\\.]*$' % re.escape(shlib_suffix)
+ for lib in map(str, libs):
+ if lib.count(".") != 4:
+ # We need a library name in libfoo.so.x.y.z form to proceed
+ raise ValueError
+ # For libfoo.so.x.y.z, links libfoo.so libfoo.so.x.y libfoo.so.x
+ major_name = shlib_suffix + "." + lib.split(".")[2]
+ minor_name = major_name + "." + lib.split(".")[3]
+ for linksuffix in [shlib_suffix, major_name, minor_name]:
+ linkname = re.sub(suffix_re, linksuffix, lib)
+ self.AddPostAction(ilibs, 'cd %s; rm -f %s; ln -s %s %s' % (destination, linkname, lib, linkname))
+ self.Clean(lib, linkname)
+ return ilibs
+
+
class OverrideEnvironment(Base):
"""A proxy that overrides variables in a wrapped construction
environment by returning values from an overrides dictionary in
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index bb7b632..e1edfdc 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -361,6 +361,7 @@ GlobalDefaultBuilders = [
'TypeLibrary',
'Zip',
'Package',
+ 'VersionedSharedLibrary',
]
for name in GlobalDefaultEnvironmentFunctions + GlobalDefaultBuilders: