Gary Oberbrunner avatar Gary Oberbrunner committed ca9eab5 Merge

Merged in managan/scons_versionedlib (pull request #82)

Versioned lib rebuild was broken

Comments (0)

Files changed (4)

src/engine/SCons/Tool/__init__.py

         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)

src/engine/SCons/Tool/__init__.xml

 <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>

src/engine/SCons/Tool/install.py

     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)
     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 "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)
             if Verbose:
-                print "make link of %s to %s" %(libname, os.path.join(install_dir, linkname))
-            fulllinkname = os.path.join(install_dir, linkname)
-            os.symlink(libname,fulllinkname)
+                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):
     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)
             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)

test/LINK/VersionedLib.py

 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:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.