diff 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
line wrap: on
line diff
--- a/mx.graal/mx_graal_8.py	Tue Dec 29 13:23:02 2015 +0100
+++ b/mx.graal/mx_graal_8.py	Wed Dec 30 18:08:59 2015 +0100
@@ -58,12 +58,18 @@
         return vm
 
 class GraalJDKDeployedDist(JvmciJDKDeployedDist):
-    def __init__(self):
-        JvmciJDKDeployedDist.__init__(self, 'GRAAL_HOTSPOT', compilers=['graal-economy', 'graal'])
+    def __init__(self, name, compilers=False, updatesGraalProperties=False):
+        JvmciJDKDeployedDist.__init__(self, name, compilers=compilers)
+        self.updatesGraalProperties = updatesGraalProperties
 
     def deploy(self, jdkDir):
         JvmciJDKDeployedDist.deploy(self, jdkDir)
-        self._updateGraalPropertiesFile(join(jdkDir, 'jre', 'lib'))
+        if self.updatesGraalProperties:
+            self._updateGraalPropertiesFile(join(jdkDir, 'jre', 'lib'))
+
+    def set_archiveparticipant(self):
+        dist = self.dist()
+        dist.set_archiveparticipant(GraalArchiveParticipant(dist))
 
     def _updateGraalPropertiesFile(self, jreLibDir):
         """
@@ -87,14 +93,14 @@
                 fp.write(os.linesep.join(content))
 
 jdkDeployedDists += [
-    JvmciJDKDeployedDist('GRAAL_OPTIONS'),
-    JvmciJDKDeployedDist('GRAAL_NODEINFO'),
-    JvmciJDKDeployedDist('GRAAL_API'),
-    JvmciJDKDeployedDist('GRAAL_COMPILER'),
-    JvmciJDKDeployedDist('GRAAL_RUNTIME'),
-    GraalJDKDeployedDist(),
-    JvmciJDKDeployedDist('GRAAL_TRUFFLE'),
-    JvmciJDKDeployedDist('GRAAL_TRUFFLE_HOTSPOT'),
+    GraalJDKDeployedDist('GRAAL_OPTIONS'),
+    GraalJDKDeployedDist('GRAAL_NODEINFO'),
+    GraalJDKDeployedDist('GRAAL_API'),
+    GraalJDKDeployedDist('GRAAL_COMPILER'),
+    GraalJDKDeployedDist('GRAAL_RUNTIME'),
+    GraalJDKDeployedDist('GRAAL_HOTSPOT', compilers=['graal-economy', 'graal'], updatesGraalProperties=True),
+    GraalJDKDeployedDist('GRAAL_TRUFFLE'),
+    GraalJDKDeployedDist('GRAAL_TRUFFLE_HOTSPOT'),
 ]
 
 mx_gate.add_jacoco_includes(['com.oracle.graal.*'])
@@ -423,6 +429,13 @@
         JVMCIArchiveParticipant.__init__(self, dist)
 
     def __add__(self, arcname, contents):
+        if arcname.startswith('META-INF/providers/'):
+            # Handles files generated by ServiceProviderProcessor
+            provider = arcname[len('META-INF/providers/'):]
+            for service in contents.strip().split(os.linesep):
+                assert service
+                self.jvmciServices.setdefault(service, []).append(provider)
+            return True
         if arcname.endswith('_OptionDescriptors.class'):
             # Need to create service files for the providers of the
             # com.oracle.graal.options.Options service created by
@@ -433,9 +446,3 @@
 
 def mx_post_parse_cmd_line(opts):
     add_bootclasspath_prepend(mx.distribution('truffle:TRUFFLE_API'))
-
-    for jdkDist in jdkDeployedDists:
-        dist = jdkDist.dist()
-        # Replace archive participant for Graal suites
-        if isinstance(jdkDist, JvmciJDKDeployedDist) and dist.suite.name != 'jvmci':
-            dist.set_archiveparticipant(GraalArchiveParticipant(dist))