comparison mx/mx_graal.py @ 21070:2ee48d02afe3

mx: Merge graal service files
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Tue, 21 Apr 2015 16:44:27 +0200
parents 59632bb8e4ad
children 5d09e1eda922
comparison
equal deleted inserted replaced
21069:38216fb8941c 21070:2ee48d02afe3
592 shutil.copyfile(src, tmp) 592 shutil.copyfile(src, tmp)
593 os.close(fd) 593 os.close(fd)
594 shutil.move(tmp, dstLib) 594 shutil.move(tmp, dstLib)
595 os.chmod(dstLib, permissions) 595 os.chmod(dstLib, permissions)
596 596
597 def _updateGraalServiceFiles(jdkDir):
598 jreGraalDir = join(jdkDir, 'jre', 'lib', 'graal')
599 graalJars = [join(jreGraalDir, e) for e in os.listdir(jreGraalDir) if e.startswith('graal') and e.endswith('.jar')]
600 jreGraalServicesDir = join(jreGraalDir, 'services')
601 if exists(jreGraalServicesDir):
602 shutil.rmtree(jreGraalServicesDir)
603 os.makedirs(jreGraalServicesDir)
604 for jar in graalJars:
605 if os.path.isfile(jar):
606 with zipfile.ZipFile(jar) as zf:
607 for member in zf.namelist():
608 if not member.startswith('META-INF/services'):
609 continue
610 serviceName = basename(member)
611 # we don't handle directories
612 assert serviceName
613 target = join(jreGraalServicesDir, serviceName)
614 lines = []
615 with zf.open(member) as serviceFile:
616 lines.extend(serviceFile.readlines())
617 if exists(target):
618 with open(target) as targetFile:
619 lines.extend(targetFile.readlines())
620 with open(target, "w+") as targetFile:
621 for line in lines:
622 targetFile.write(line.rstrip() + os.linesep)
623
624
625
597 def _installDistInJdks(deployableDist): 626 def _installDistInJdks(deployableDist):
598 """ 627 """
599 Installs the jar(s) for a given Distribution into all existing Graal JDKs 628 Installs the jar(s) for a given Distribution into all existing Graal JDKs
600 """ 629 """
601 630
611 _update_graalRuntime_inline_hpp(dist) 640 _update_graalRuntime_inline_hpp(dist)
612 jdks = _jdksDir() 641 jdks = _jdksDir()
613 642
614 if exists(jdks): 643 if exists(jdks):
615 for e in os.listdir(jdks): 644 for e in os.listdir(jdks):
616 jreLibDir = join(jdks, e, 'jre', 'lib') 645 jdkDir = join(jdks, e)
646 jreLibDir = join(jdkDir, 'jre', 'lib')
617 if exists(jreLibDir): 647 if exists(jreLibDir):
618 if deployableDist.isExtension: 648 if deployableDist.isExtension:
619 targetDir = join(jreLibDir, 'ext') 649 targetDir = join(jreLibDir, 'ext')
620 elif deployableDist.isGraalClassLoader: 650 elif deployableDist.isGraalClassLoader:
621 targetDir = join(jreLibDir, 'graal') 651 targetDir = join(jreLibDir, 'graal')
623 targetDir = jreLibDir 653 targetDir = jreLibDir
624 if not exists(targetDir): 654 if not exists(targetDir):
625 os.makedirs(targetDir) 655 os.makedirs(targetDir)
626 _copyToJdk(dist.path, targetDir) 656 _copyToJdk(dist.path, targetDir)
627 if dist.sourcesPath: 657 if dist.sourcesPath:
628 _copyToJdk(dist.sourcesPath, join(jdks, e)) 658 _copyToJdk(dist.sourcesPath, jdkDir)
629 # deploy service files
630 if deployableDist.isGraalClassLoader: 659 if deployableDist.isGraalClassLoader:
631 # deploy services files 660 # deploy service files
632 jreGraalServicesDir = join(jreLibDir, 'graal', 'services') 661 _updateGraalServiceFiles(jdkDir)
633 if not exists(jreGraalServicesDir):
634 os.makedirs(jreGraalServicesDir)
635 with zipfile.ZipFile(dist.path) as zf:
636 for member in zf.namelist():
637 if not member.startswith('META-INF/services'):
638 continue
639 serviceName = basename(member)
640 # we don't handle directories
641 assert serviceName
642 target = join(jreGraalServicesDir, serviceName)
643 with zf.open(member) as serviceFile, open(target, "w+") as targetFile:
644 shutil.copyfileobj(serviceFile, targetFile)
645 662
646 # run a command in the windows SDK Debug Shell 663 # run a command in the windows SDK Debug Shell
647 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo=None): 664 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo=None):
648 if respondTo is None: 665 if respondTo is None:
649 respondTo = {} 666 respondTo = {}