Mercurial > hg > truffle
comparison mx/mx_graal.py @ 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 | 3b4690ddd92e |
children | 6140fd60abe9 |
comparison
equal
deleted
inserted
replaced
16196:8bf243c2c87b | 16197:97a10428ff2c |
---|---|
503 if exists(jdks): | 503 if exists(jdks): |
504 for e in os.listdir(jdks): | 504 for e in os.listdir(jdks): |
505 jreLibDir = join(jdks, e, 'jre', 'lib') | 505 jreLibDir = join(jdks, e, 'jre', 'lib') |
506 if exists(jreLibDir): | 506 if exists(jreLibDir): |
507 def install(srcJar, dstDir): | 507 def install(srcJar, dstDir): |
508 # do a copy and then a move to get atomic updating (on Unix) | |
509 name = os.path.basename(srcJar) | 508 name = os.path.basename(srcJar) |
510 fd, tmp = tempfile.mkstemp(suffix='', prefix=name, dir=dstDir) | |
511 shutil.copyfile(srcJar, tmp) | |
512 os.close(fd) | |
513 dstJar = join(dstDir, name) | 509 dstJar = join(dstDir, name) |
514 shutil.move(tmp, dstJar) | 510 if mx.get_env('SYMLINK_GRAAL_JAR', None) == 'true': |
515 os.chmod(dstJar, JDK_UNIX_PERMISSIONS) | 511 # Using symlinks is much faster than copying but may |
512 # cause issues if graal.jar is being updated while | |
513 # the VM is running. | |
514 if not os.path.islink(dstJar) or not os.path.realpath(dstJar) == srcJar: | |
515 if exists(dstJar): | |
516 os.remove(dstJar) | |
517 os.symlink(srcJar, dstJar) | |
518 else: | |
519 # do a copy and then a move to get atomic updating (on Unix) | |
520 fd, tmp = tempfile.mkstemp(suffix='', prefix=name, dir=dstDir) | |
521 shutil.copyfile(srcJar, tmp) | |
522 os.close(fd) | |
523 shutil.move(tmp, dstJar) | |
524 os.chmod(dstJar, JDK_UNIX_PERMISSIONS) | |
516 | 525 |
517 install(graalJar, jreLibDir) | 526 install(graalJar, jreLibDir) |
518 if graalDist.sourcesPath: | 527 if graalDist.sourcesPath: |
519 install(graalDist.sourcesPath, join(jdks, e)) | 528 install(graalDist.sourcesPath, join(jdks, e)) |
520 | 529 |