comparison mx.graal/mx_graal_8.py @ 23222:56359eb3abfa

moved @ServiceProvider mechanism from JVMCI to Graal (GRAAL-1380)
author Doug Simon <doug.simon@oracle.com>
date Wed, 30 Dec 2015 18:08:59 +0100
parents 75a807751aa6
children f0e34c710768
comparison
equal deleted inserted replaced
23221:815f05c8dc0b 23222:56359eb3abfa
56 # mx_jvmci:8 56 # mx_jvmci:8
57 assert isinstance(vm, str) 57 assert isinstance(vm, str)
58 return vm 58 return vm
59 59
60 class GraalJDKDeployedDist(JvmciJDKDeployedDist): 60 class GraalJDKDeployedDist(JvmciJDKDeployedDist):
61 def __init__(self): 61 def __init__(self, name, compilers=False, updatesGraalProperties=False):
62 JvmciJDKDeployedDist.__init__(self, 'GRAAL_HOTSPOT', compilers=['graal-economy', 'graal']) 62 JvmciJDKDeployedDist.__init__(self, name, compilers=compilers)
63 self.updatesGraalProperties = updatesGraalProperties
63 64
64 def deploy(self, jdkDir): 65 def deploy(self, jdkDir):
65 JvmciJDKDeployedDist.deploy(self, jdkDir) 66 JvmciJDKDeployedDist.deploy(self, jdkDir)
66 self._updateGraalPropertiesFile(join(jdkDir, 'jre', 'lib')) 67 if self.updatesGraalProperties:
68 self._updateGraalPropertiesFile(join(jdkDir, 'jre', 'lib'))
69
70 def set_archiveparticipant(self):
71 dist = self.dist()
72 dist.set_archiveparticipant(GraalArchiveParticipant(dist))
67 73
68 def _updateGraalPropertiesFile(self, jreLibDir): 74 def _updateGraalPropertiesFile(self, jreLibDir):
69 """ 75 """
70 Updates (or creates) 'jreLibDir'/jvmci/graal.properties to set/modify the 76 Updates (or creates) 'jreLibDir'/jvmci/graal.properties to set/modify the
71 graal.version property. 77 graal.version property.
85 content.append(line.rstrip(os.linesep)) 91 content.append(line.rstrip(os.linesep))
86 with open(graalProperties, 'w') as fp: 92 with open(graalProperties, 'w') as fp:
87 fp.write(os.linesep.join(content)) 93 fp.write(os.linesep.join(content))
88 94
89 jdkDeployedDists += [ 95 jdkDeployedDists += [
90 JvmciJDKDeployedDist('GRAAL_OPTIONS'), 96 GraalJDKDeployedDist('GRAAL_OPTIONS'),
91 JvmciJDKDeployedDist('GRAAL_NODEINFO'), 97 GraalJDKDeployedDist('GRAAL_NODEINFO'),
92 JvmciJDKDeployedDist('GRAAL_API'), 98 GraalJDKDeployedDist('GRAAL_API'),
93 JvmciJDKDeployedDist('GRAAL_COMPILER'), 99 GraalJDKDeployedDist('GRAAL_COMPILER'),
94 JvmciJDKDeployedDist('GRAAL_RUNTIME'), 100 GraalJDKDeployedDist('GRAAL_RUNTIME'),
95 GraalJDKDeployedDist(), 101 GraalJDKDeployedDist('GRAAL_HOTSPOT', compilers=['graal-economy', 'graal'], updatesGraalProperties=True),
96 JvmciJDKDeployedDist('GRAAL_TRUFFLE'), 102 GraalJDKDeployedDist('GRAAL_TRUFFLE'),
97 JvmciJDKDeployedDist('GRAAL_TRUFFLE_HOTSPOT'), 103 GraalJDKDeployedDist('GRAAL_TRUFFLE_HOTSPOT'),
98 ] 104 ]
99 105
100 mx_gate.add_jacoco_includes(['com.oracle.graal.*']) 106 mx_gate.add_jacoco_includes(['com.oracle.graal.*'])
101 mx_gate.add_jacoco_excluded_annotations(['@Snippet', '@ClassSubstitution']) 107 mx_gate.add_jacoco_excluded_annotations(['@Snippet', '@ClassSubstitution'])
102 108
421 class GraalArchiveParticipant(JVMCIArchiveParticipant): 427 class GraalArchiveParticipant(JVMCIArchiveParticipant):
422 def __init__(self, dist): 428 def __init__(self, dist):
423 JVMCIArchiveParticipant.__init__(self, dist) 429 JVMCIArchiveParticipant.__init__(self, dist)
424 430
425 def __add__(self, arcname, contents): 431 def __add__(self, arcname, contents):
432 if arcname.startswith('META-INF/providers/'):
433 # Handles files generated by ServiceProviderProcessor
434 provider = arcname[len('META-INF/providers/'):]
435 for service in contents.strip().split(os.linesep):
436 assert service
437 self.jvmciServices.setdefault(service, []).append(provider)
438 return True
426 if arcname.endswith('_OptionDescriptors.class'): 439 if arcname.endswith('_OptionDescriptors.class'):
427 # Need to create service files for the providers of the 440 # Need to create service files for the providers of the
428 # com.oracle.graal.options.Options service created by 441 # com.oracle.graal.options.Options service created by
429 # com.oracle.graal.options.processor.OptionProcessor. 442 # com.oracle.graal.options.processor.OptionProcessor.
430 provider = arcname[:-len('.class'):].replace('/', '.') 443 provider = arcname[:-len('.class'):].replace('/', '.')
431 self.services.setdefault('com.oracle.graal.options.OptionDescriptors', []).append(provider) 444 self.services.setdefault('com.oracle.graal.options.OptionDescriptors', []).append(provider)
432 return JVMCIArchiveParticipant.__add__(self, arcname, contents) 445 return JVMCIArchiveParticipant.__add__(self, arcname, contents)
433 446
434 def mx_post_parse_cmd_line(opts): 447 def mx_post_parse_cmd_line(opts):
435 add_bootclasspath_prepend(mx.distribution('truffle:TRUFFLE_API')) 448 add_bootclasspath_prepend(mx.distribution('truffle:TRUFFLE_API'))
436
437 for jdkDist in jdkDeployedDists:
438 dist = jdkDist.dist()
439 # Replace archive participant for Graal suites
440 if isinstance(jdkDist, JvmciJDKDeployedDist) and dist.suite.name != 'jvmci':
441 dist.set_archiveparticipant(GraalArchiveParticipant(dist))