Commits

Rob Managan  committed e12adc6

Add code to delete any current symlink before trying to crete them. Before the step of creating the symlink would fail.
Also update the code in install.py to create the same chain of links as __init__.py did. The installed links to the shared library all pointed at the shared library instead of to the next one in the chain with more version numbers

  • Participants
  • Parent commits 0c9c8af

Comments (0)

Files changed (2)

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

File 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):