diff mx/mx_graal.py @ 15873:6dcf8ab4ad86

HotSpotOptions.inline.hpp generator writes to System.out to make generator errors more visible (they will show up when compiling the generated source)
author Doug Simon <doug.simon@oracle.com>
date Sat, 24 May 2014 00:46:33 +0200
parents fe608a56e3f7
children db776f9bea7c
line wrap: on
line diff
--- a/mx/mx_graal.py	Sat May 24 00:25:29 2014 +0200
+++ b/mx/mx_graal.py	Sat May 24 00:46:33 2014 +0200
@@ -491,23 +491,16 @@
     hsSrcGenDir = join(p.source_gen_dir(), 'hotspot')
     if not exists(hsSrcGenDir):
         os.makedirs(hsSrcGenDir)
-    path = join(hsSrcGenDir, 'HotSpotOptions.inline.hpp')
-    fd, tmp = tempfile.mkstemp(suffix='', prefix='HotSpotOptions.inline.hpp', dir=hsSrcGenDir)
-    os.close(fd)
-    try:
-        retcode = mx.run_java(['-cp', graalJar, mainClass, tmp], nonZeroIsFatal=False)
-        if retcode != 0:
-            # Suppress the error if it's because the utility class isn't compiled yet
-            with zipfile.ZipFile(graalJar, 'r') as zf:
-                mainClassFile = mainClass.replace('.', '/') + '.class'
-                if mainClassFile not in zf.namelist():
-                    return
-            mx.abort(retcode)
-        with open(tmp) as fp:
-            content = fp.read()
-        mx.update_file(path, content)
-    finally:
-        os.remove(tmp)
+    tmp = StringIO.StringIO()
+    retcode = mx.run_java(['-cp', graalJar, mainClass], out=tmp.write, nonZeroIsFatal=False)
+    if retcode != 0:
+        # Suppress the error if it's because the utility class isn't compiled yet
+        with zipfile.ZipFile(graalJar, 'r') as zf:
+            mainClassFile = mainClass.replace('.', '/') + '.class'
+            if mainClassFile not in zf.namelist():
+                return
+        mx.abort(retcode)
+    mx.update_file(join(hsSrcGenDir, 'HotSpotOptions.inline.hpp'), tmp.getvalue())
 
 def _installGraalJarInJdks(graalDist):
     graalJar = graalDist.path