changeset 16197:97a10428ff2c

mx: added support for SYMLINK_GRAAL_JAR env var which controls use of symlinks instead of copying when installing graal.jar into the local JDK(s) (disabled by default)
author Doug Simon <doug.simon@oracle.com>
date Fri, 20 Jun 2014 15:23:12 +0200
parents 8bf243c2c87b
children 006d99164743
files mx/mx_graal.py
diffstat 1 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mx/mx_graal.py	Fri Jun 20 15:18:38 2014 +0200
+++ b/mx/mx_graal.py	Fri Jun 20 15:23:12 2014 +0200
@@ -505,14 +505,23 @@
             jreLibDir = join(jdks, e, 'jre', 'lib')
             if exists(jreLibDir):
                 def install(srcJar, dstDir):
-                    # do a copy and then a move to get atomic updating (on Unix)
                     name = os.path.basename(srcJar)
-                    fd, tmp = tempfile.mkstemp(suffix='', prefix=name, dir=dstDir)
-                    shutil.copyfile(srcJar, tmp)
-                    os.close(fd)
                     dstJar = join(dstDir, name)
-                    shutil.move(tmp, dstJar)
-                    os.chmod(dstJar, JDK_UNIX_PERMISSIONS)
+                    if mx.get_env('SYMLINK_GRAAL_JAR', None) == 'true':
+                        # Using symlinks is much faster than copying but may
+                        # cause issues if graal.jar is being updated while
+                        # the VM is running.
+                        if not os.path.islink(dstJar) or not os.path.realpath(dstJar) == srcJar:
+                            if exists(dstJar):
+                                os.remove(dstJar)
+                            os.symlink(srcJar, dstJar)
+                    else:
+                        # do a copy and then a move to get atomic updating (on Unix)
+                        fd, tmp = tempfile.mkstemp(suffix='', prefix=name, dir=dstDir)
+                        shutil.copyfile(srcJar, tmp)
+                        os.close(fd)
+                        shutil.move(tmp, dstJar)
+                        os.chmod(dstJar, JDK_UNIX_PERMISSIONS)
 
                 install(graalJar, jreLibDir)
                 if graalDist.sourcesPath: