diff options
author | Gary Oberbrunner <garyo@oberbrunner.com> | 2013-08-25 13:52:17 (GMT) |
---|---|---|
committer | Gary Oberbrunner <garyo@oberbrunner.com> | 2013-08-25 13:52:17 (GMT) |
commit | 7ab739749c14c44f48e526ec7756870006155639 (patch) | |
tree | c90a8a0eb1bcc0557a3cabca03b6fe3e13c43b95 | |
parent | d9ee0920aa8f861e326ffb8278661de58dacbac8 (diff) | |
parent | 0e60308e51dbb9f285737c3375dfd24260babb06 (diff) | |
download | SCons-7ab739749c14c44f48e526ec7756870006155639.zip SCons-7ab739749c14c44f48e526ec7756870006155639.tar.gz SCons-7ab739749c14c44f48e526ec7756870006155639.tar.bz2 |
Merged in managan/scons_versionedlib (pull request #82)
Versioned lib rebuild was broken
-rw-r--r-- | src/engine/SCons/Tool/__init__.py | 18 | ||||
-rw-r--r-- | src/engine/SCons/Tool/__init__.xml | 2 | ||||
-rw-r--r-- | src/engine/SCons/Tool/install.py | 41 | ||||
-rw-r--r-- | test/LINK/VersionedLib.py | 13 |
4 files changed, 64 insertions, 10 deletions
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index af1282c..b80d6e4 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -337,15 +337,23 @@ symlinks for the platform we are on""" for count in range(len(linknames)): linkname = linknames[count] if count > 0: - os.symlink(os.path.basename(linkname),lastname) + try: + os.remove(lastlinkname) + except: + pass + os.symlink(os.path.basename(linkname),lastlinkname) if Verbose: - print "VerShLib: made sym link of %s -> %s" % (lastname,linkname) - lastname = linkname + 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: - os.symlink(lib_ver,lastname) + try: + os.remove(lastlinkname) + except: + pass + os.symlink(lib_ver,lastlinkname) if Verbose: - print "VerShLib: made sym link of %s -> %s" % (lib_ver,linkname) + print "VerShLib: made sym link of %s -> %s" % (linkname, lib_ver) return result ShLibAction = SCons.Action.Action(VersionedSharedLibrary, None) diff --git a/src/engine/SCons/Tool/__init__.xml b/src/engine/SCons/Tool/__init__.xml index 9c3dc85..0918b46 100644 --- a/src/engine/SCons/Tool/__init__.xml +++ b/src/engine/SCons/Tool/__init__.xml @@ -208,7 +208,7 @@ alpha, beta, or release candidate patch levels. <para> This builder may create multiple links to the library. On a POSIX system, for the shared library libbar.so.2.3.1, the links created would be -libbar.so, libbar.so.2, and libbar.so.2.3; on a Darwin (OSX) system +libbar.so and libbar.so.2; on a Darwin (OSX) system the library would be libbar.2.3.1.dylib and the link would be libbar.dylib. </para> diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py index 9aa9d46..0c81d05 100644 --- a/src/engine/SCons/Tool/install.py +++ b/src/engine/SCons/Tool/install.py @@ -133,6 +133,11 @@ def copyFuncVersionedLib(dest, source, env): if os.path.isdir(source): raise SCons.Errors.UserError("cannot install directory `%s' as a version library" % str(source) ) else: + # remove the link if it is already there + try: + os.remove(dest) + except: + pass shutil.copy2(source, dest) st = os.stat(source) os.chmod(dest, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE) @@ -196,11 +201,34 @@ def versionedLibLinks(dest, source, env): if version != None: # libname includes the version number if one was given linknames = SCons.Tool.VersionShLibLinkNames(version,libname,env) - for linkname in linknames: - if Verbose: - print "make link of %s to %s" %(libname, os.path.join(install_dir, linkname)) + if Verbose: + print "versionedLibLinks: linknames ",linknames + # Here we just need the file name w/o path as the target of the link + lib_ver = libname + # make symlink of adjacent names in linknames + for count in range(len(linknames)): + linkname = linknames[count] fulllinkname = os.path.join(install_dir, linkname) - os.symlink(libname,fulllinkname) + if Verbose: + print "full link name ",fulllinkname + if count > 0: + try: + os.remove(lastlinkname) + except: + pass + os.symlink(os.path.basename(fulllinkname),lastlinkname) + if Verbose: + print "versionedLibLinks: made sym link of %s -> %s" % (lastlinkname,os.path.basename(fulllinkname)) + lastlinkname = fulllinkname + # 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) + if Verbose: + print "versionedLibLinks: made sym link of %s -> %s" % (lib_ver,lastlinkname) return def installFunc(target, source, env): @@ -269,6 +297,8 @@ def add_versioned_targets_to_INSTALLED_FILES(target, source, env): global _INSTALLED_FILES, _UNIQUE_INSTALLED_FILES Verbose = False _INSTALLED_FILES.extend(target) + if Verbose: + 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) @@ -281,6 +311,9 @@ def add_versioned_targets_to_INSTALLED_FILES(target, source, env): fulllinkname = os.path.join(install_dir, linkname) env.SideEffect(fulllinkname,target[0]) env.Clean(target[0],fulllinkname) + _INSTALLED_FILES.append(fulllinkname) + if Verbose: + print "installed list ", _INSTALLED_FILES _UNIQUE_INSTALLED_FILES = None return (target, source) diff --git a/test/LINK/VersionedLib.py b/test/LINK/VersionedLib.py index 3c92252..a2345d6 100644 --- a/test/LINK/VersionedLib.py +++ b/test/LINK/VersionedLib.py @@ -135,6 +135,19 @@ for f in files: for f in instfiles:
test.must_exist(['installtest', f])
+# modify test.c and make sure it can recompile when links already exist
+test.write('test.c', """\
+#if _WIN32
+__declspec(dllexport)
+#endif
+int testlib(int n)
+{
+return n+11 ;
+}
+""")
+
+test.run()
+
test.run(arguments = '-c')
for f in files:
|