Mercurial > hg > graal-compiler
comparison mx/mx_graal.py @ 21099:3f51d02e536f
Make should export graal service files
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Thu, 23 Apr 2015 14:49:24 +0200 |
parents | 5d09e1eda922 |
children | 9690597d7a29 |
comparison
equal
deleted
inserted
replaced
21098:5d09e1eda922 | 21099:3f51d02e536f |
---|---|
616 superInterface = superInterface[:superInterface.index('<')] | 616 superInterface = superInterface[:superInterface.index('<')] |
617 if _isGraalService(superInterface, graalJars): | 617 if _isGraalService(superInterface, graalJars): |
618 return True | 618 return True |
619 return False | 619 return False |
620 | 620 |
621 def _updateGraalServiceFiles(jdkDir): | 621 def _extractGraalServiceFiles(graalJars, destination, cleanDestination=True): |
622 jreGraalDir = join(jdkDir, 'jre', 'lib', 'graal') | 622 services = set() |
623 graalJars = [join(jreGraalDir, e) for e in os.listdir(jreGraalDir) if e.startswith('graal') and e.endswith('.jar')] | 623 if cleanDestination: |
624 jreGraalServicesDir = join(jreGraalDir, 'services') | 624 if exists(destination): |
625 if exists(jreGraalServicesDir): | 625 shutil.rmtree(destination) |
626 shutil.rmtree(jreGraalServicesDir) | 626 os.makedirs(destination) |
627 os.makedirs(jreGraalServicesDir) | |
628 for jar in graalJars: | 627 for jar in graalJars: |
629 if os.path.isfile(jar): | 628 if os.path.isfile(jar): |
630 with zipfile.ZipFile(jar) as zf: | 629 with zipfile.ZipFile(jar) as zf: |
631 for member in zf.namelist(): | 630 for member in zf.namelist(): |
632 if not member.startswith('META-INF/services'): | 631 if not member.startswith('META-INF/services'): |
634 serviceName = basename(member) | 633 serviceName = basename(member) |
635 # we don't handle directories | 634 # we don't handle directories |
636 assert serviceName and member == 'META-INF/services/' + serviceName | 635 assert serviceName and member == 'META-INF/services/' + serviceName |
637 if not _isGraalService(serviceName, graalJars): | 636 if not _isGraalService(serviceName, graalJars): |
638 continue | 637 continue |
639 target = join(jreGraalServicesDir, serviceName) | 638 services.add(serviceName) |
639 target = join(destination, serviceName) | |
640 lines = [] | 640 lines = [] |
641 with zf.open(member) as serviceFile: | 641 with zf.open(member) as serviceFile: |
642 lines.extend(serviceFile.readlines()) | 642 lines.extend(serviceFile.readlines()) |
643 if exists(target): | 643 if exists(target): |
644 with open(target) as targetFile: | 644 with open(target) as targetFile: |
645 lines.extend(targetFile.readlines()) | 645 lines.extend(targetFile.readlines()) |
646 with open(target, "w+") as targetFile: | 646 with open(target, "w+") as targetFile: |
647 for line in lines: | 647 for line in lines: |
648 targetFile.write(line.rstrip() + os.linesep) | 648 targetFile.write(line.rstrip() + os.linesep) |
649 return services | |
650 | |
651 def _updateGraalServiceFiles(jdkDir): | |
652 jreGraalDir = join(jdkDir, 'jre', 'lib', 'graal') | |
653 graalJars = [join(jreGraalDir, e) for e in os.listdir(jreGraalDir) if e.startswith('graal') and e.endswith('.jar')] | |
654 jreGraalServicesDir = join(jreGraalDir, 'services') | |
655 _extractGraalServiceFiles(graalJars, jreGraalServicesDir) | |
649 | 656 |
650 | 657 |
651 | 658 |
652 def _installDistInJdks(deployableDist): | 659 def _installDistInJdks(deployableDist): |
653 """ | 660 """ |
843 assert os.path.isdir(opts2.export_dir), '{0} is not a directory'.format(opts2.export_dir) | 850 assert os.path.isdir(opts2.export_dir), '{0} is not a directory'.format(opts2.export_dir) |
844 | 851 |
845 defsPath = join(_graal_home, 'make', 'defs.make') | 852 defsPath = join(_graal_home, 'make', 'defs.make') |
846 with open(defsPath) as fp: | 853 with open(defsPath) as fp: |
847 defs = fp.read() | 854 defs = fp.read() |
855 graalJars = [] | |
848 for jdkDist in _jdkDeployedDists: | 856 for jdkDist in _jdkDeployedDists: |
849 dist = mx.distribution(jdkDist.name) | 857 dist = mx.distribution(jdkDist.name) |
850 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path) | 858 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path) |
851 if jdkDist.isExtension: | 859 if jdkDist.isExtension: |
852 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_EXT_DIR)/' + basename(dist.path) | 860 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_EXT_DIR)/' + basename(dist.path) |
853 elif jdkDist.isGraalClassLoader: | 861 elif jdkDist.isGraalClassLoader: |
854 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_DIR)/' + basename(dist.path) | 862 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_DIR)/' + basename(dist.path) |
863 graalJars.append(dist.path) | |
855 else: | 864 else: |
856 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path) | 865 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path) |
857 if defLine not in defs: | 866 if defLine not in defs: |
858 mx.abort('Missing following line in ' + defsPath + '\n' + defLine) | 867 mx.abort('Missing following line in ' + defsPath + '\n' + defLine) |
859 shutil.copy(dist.path, opts2.export_dir) | 868 shutil.copy(dist.path, opts2.export_dir) |
869 services = _extractGraalServiceFiles(graalJars, join(opts2.export_dir, 'services')) | |
870 for service in services: | |
871 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/' + service | |
872 if defLine not in defs: | |
873 mx.abort('Missing following line in ' + defsPath + ' for service from ' + dist.name + '\n' + defLine) | |
860 graalOptions = join(_graal_home, 'graal.options') | 874 graalOptions = join(_graal_home, 'graal.options') |
861 if exists(graalOptions): | 875 if exists(graalOptions): |
862 shutil.copy(graalOptions, opts2.export_dir) | 876 shutil.copy(graalOptions, opts2.export_dir) |
863 | 877 |
864 if not _vmSourcesAvailable or not opts2.native: | 878 if not _vmSourcesAvailable or not opts2.native: |