changeset 5152:cfdb3c24bd6c

changed Graal class path declaration (back) to a constant that is checked for correctness during building
author Doug Simon <doug.simon@oracle.com>
date Fri, 23 Mar 2012 11:48:39 +0100
parents 5717fc2be01c
children 57546200db29
files mx/commands.py src/share/vm/runtime/arguments.cpp
diffstat 2 files changed, 45 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mx/commands.py	Thu Mar 22 19:06:04 2012 -0700
+++ b/mx/commands.py	Fri Mar 23 11:48:39 2012 +0100
@@ -437,6 +437,27 @@
             if not 'Xusage.txt' in line:
                 sys.stderr.write(line + os.linesep)
                 
+        # Update graal_paths.hpp
+        #for p in mx.project('com.oracle.max.graal.hotspot').all_deps([], False):
+        #    out.write('    prepend_to_graal_classpath(scp_compiler, graal_dir, "' + p.name + '");\n')
+        argumentsCpp = join(_graal_home, 'src', 'share', 'vm', 'runtime', 'arguments.cpp')
+        assert exists(argumentsCpp), 'File does not exist: ' + argumentsCpp
+        with open(argumentsCpp) as fp:
+            source = fp.read();
+            decl = 'const char* graal_projects[] = {'
+            start = source.find(decl)
+            assert start != -1, 'Could not find "' + decl + '" in ' + fp.name
+            end = source.find('};', start)
+            assert end != -1, 'Could not find "' + decl + '" ... "};" in ' + fp.name
+            actual = frozenset([a.strip().strip('"') for a in source[start + len(decl):end].split(',')])
+            expected = frozenset([p.name for p in mx.project('com.oracle.graal.hotspot').all_deps([], False)])
+            missing = expected - actual
+            extra = actual - expected
+            if len(missing) != 0:
+                mx.abort(fp.name + ':' + str(source[:start].count('\n') + 1) + ': add missing projects to declaration: ' + ','.join(missing))
+            if len(extra) != 0:
+                mx.abort(fp.name + ':' + str(source[:start].count('\n') + 1) + ': remove projects from declaration: ' + ','.join(extra))
+                
         if platform.system() == 'Windows':
             compilelogfile = _graal_home + '/graalCompile.log'
             mksHome = mx.get_env('MKS_HOME', 'C:\\cygwin\\bin')
--- a/src/share/vm/runtime/arguments.cpp	Thu Mar 22 19:06:04 2012 -0700
+++ b/src/share/vm/runtime/arguments.cpp	Fri Mar 23 11:48:39 2012 +0100
@@ -2127,21 +2127,33 @@
     }
     if (PrintVMOptions) tty->print_cr("GRAAL=%s", graal_dir);
     
+    // this declaration is checked for correctness by 'mx build' - only
+    // modify its entries, not its name or shape
+    const char* graal_projects[] = {
+        "com.oracle.max.criutils",
+        "com.oracle.graal.hotspot",
+        "com.oracle.max.asm",
+        "com.oracle.graal.alloc",
+        "com.oracle.graal.snippets",
+        "com.oracle.graal.compiler",
+        "com.oracle.graal.nodes",
+        "com.oracle.graal.printer",
+        "com.oracle.max.cri",
+        "com.oracle.graal.debug",
+        "com.oracle.graal.graph",
+        "com.oracle.graal.lir",
+        "com.oracle.graal.lir.amd64",
+        "com.oracle.graal.java"
+    };
+
     SysClassPath scp_compiler("");
-    struct dirent* dentry;
-    char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(graal_dir));
-    errno = 0;
-    DIR* graal_dir_handle = os::opendir(graal_dir);
-    while ((dentry = os::readdir(graal_dir_handle, (struct dirent *)tdbuf)) != NULL) {
-      if (strcmp(dentry->d_name, ".") != 0 && strcmp(dentry->d_name, "..") != 0 && strcmp(dentry->d_name, "com.oracle.graal.tests") != 0 && strcmp(dentry->d_name, "com.oracle.graal.jtt") != 0) {
-        prepend_to_graal_classpath(scp_compiler, graal_dir, dentry->d_name);
-        if (PrintVMOptions) {
-          tty->print_cr("Adding project directory %s to bootclasspath", dentry->d_name);
-        }
+    const int len = sizeof(graal_projects) / sizeof(char*);
+    for (int i = 0; i < len; i++) {
+      if (PrintVMOptions) {
+        tty->print_cr("Adding project directory %s to bootclasspath", graal_projects[i]);
       }
+      prepend_to_graal_classpath(scp_compiler, graal_dir, graal_projects[i]);
     }
-    os::closedir(graal_dir_handle);
-    FREE_C_HEAP_ARRAY(char, tdbuf);
     scp_compiler.expand_endorsed();
 
     Arguments::set_compilerclasspath(scp_compiler.combined_path());