changeset 4252:67e88b7624d5

Removed need for GRAAL environment variable on Windows.
author Doug Simon <doug.simon@oracle.com>
date Mon, 09 Jan 2012 22:01:39 +0100
parents 44f3dae303ae
children fc2f14acd5a5 1cf920630944 fa85381ac428
files mx/commands.py mxtool/mx.py src/share/vm/runtime/arguments.cpp
diffstat 3 files changed, 35 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mx/commands.py	Mon Jan 09 16:03:02 2012 +0100
+++ b/mx/commands.py	Mon Jan 09 22:01:39 2012 +0100
@@ -35,8 +35,6 @@
 _graal_home = dirname(dirname(__file__))
 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src')) 
 _vmbuild = 'product'
-_winSDK = 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\'
-_mksHome = 'C:\\cygwin\\bin'
 
 def clean(args):
     """cleans the GraalVM source tree"""
@@ -191,11 +189,14 @@
     Get the JDK into which Graal is installed, creating it first if necessary.
     """
     jdk = join(_graal_home, 'jdk' + mx.java().version)
+    jdkContents = ['bin', 'db', 'include', 'jre', 'lib']
+    if mx.get_os() != 'windows':
+        jdkContents.append('man')
     if not exists(jdk):
         srcJdk = mx.java().jdk
         mx.log('Creating ' + jdk + ' from ' + srcJdk)
         os.mkdir(jdk)
-        for d in ['bin', 'db', 'include', 'jre', 'lib', 'man']:
+        for d in jdkContents:
             src = join(srcJdk, d)
             dst = join(jdk, d)
             if not exists(src):
@@ -226,7 +227,7 @@
                 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') 
             mx.log('Creating ' + res)
             os.mkdir(res)
-            for d in ['bin', 'db', 'include', 'jre', 'lib', 'man']:
+            for d in jdkContents:
                 shutil.copytree(join(jdk, d), join(res, d))
         return res
     else:
@@ -237,8 +238,11 @@
     newLine = os.linesep
     STARTTOKEN = 'RUNINDEBUGSHELL_STARTSEQUENCE'
     ENDTOKEN = 'RUNINDEBUGSHELL_ENDSEQUENCE'
-    p = subprocess.Popen('cmd.exe /E:ON /V:ON /K ""' + _winSDK + '/Bin/SetEnv.cmd" & echo ' + STARTTOKEN + '"', \
-            shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+    
+    winSDK = mx.get_env('WIN_SDK', 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\')
+
+    p = subprocess.Popen('cmd.exe /E:ON /V:ON /K ""' + winSDK + '/Bin/SetEnv.cmd" & echo ' + STARTTOKEN + '"', \
+            shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
     output = p.stdout
     input = p.stdin
     if logFile:
@@ -302,8 +306,10 @@
                 
         if platform.system() == 'Windows':
             compilelogfile = _graal_home + '/graalCompile.log'
+            mksHome = mx.get_env('MKS_HOME', 'C:\\cygwin\\bin')
+
             _runInDebugShell('msbuild ' + _graal_home + r'\build\vs-amd64\jvm.vcproj /p:Configuration=compiler1_product /target:clean', _graal_home)
-            winCompileCmd = r'set HotSpotMksHome=' + _mksHome + r'& set OUT_DIR=' + jdk + r'& set JAVA_HOME=' + jdk + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' +_graal_home + r'\make\windows"& call create.bat ' + _graal_home + ''
+            winCompileCmd = r'set HotSpotMksHome=' + mksHome + r'& set OUT_DIR=' + jdk + r'& set JAVA_HOME=' + jdk + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' +_graal_home + r'\make\windows"& call create.bat ' + _graal_home + ''
             print(winCompileCmd)
             winCompileSuccess = re.compile(r"^Writing \.vcxproj file:")
             if not _runInDebugShell(winCompileCmd, _graal_home, compilelogfile, winCompileSuccess):
--- a/mxtool/mx.py	Mon Jan 09 16:03:02 2012 +0100
+++ b/mxtool/mx.py	Mon Jan 09 22:01:39 2012 +0100
@@ -544,7 +544,6 @@
         remaining = end - time.time()
         if remaining <= 0:
             abort('Process timed out after {0} seconds: {1}'.format(timeout, ' '.join(args)))
-            _kill_process_group(process.pid)
         delay = min(delay * 2, remaining, .05)
         time.sleep(delay)
 
@@ -576,11 +575,16 @@
     try:
         # On Unix, the new subprocess should be in a separate group so that a timeout alarm
         # can use os.killpg() to kill the whole subprocess group
-        preexec_fn = os.setsid if get_os() != 'windows' else None
+        preexec_fn = None
+        creationflags = 0
+        if get_os() == 'windows':
+            creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
+        else:
+            preexec_fn = os.setsid  
         
         if not callable(out) and not callable(err) and timeout is None:
             # The preexec_fn=os.setsid
-            p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn)
+            p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn, creationflags=creationflags)
             _currentSubprocess = (p, args)
             retcode = p.wait()
         else:
@@ -590,7 +594,7 @@
                 stream.close()
             stdout=out if not callable(out) else subprocess.PIPE
             stderr=err if not callable(err) else subprocess.PIPE
-            p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn)
+            p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags)
             _currentSubprocess = (p, args)
             if callable(out):
                 t = Thread(target=redirect, args=(p.stdout, out))
@@ -744,7 +748,10 @@
     currentSubprocess = _currentSubprocess
     if currentSubprocess is not None:
         p, _ = currentSubprocess
-        _kill_process_group(p.pid)
+        if get_os() == 'windows':
+            p.kill()
+        else:
+            _kill_process_group(p.pid)
     
     raise SystemExit(codeOrMessage)
 
--- a/src/share/vm/runtime/arguments.cpp	Mon Jan 09 16:03:02 2012 +0100
+++ b/src/share/vm/runtime/arguments.cpp	Mon Jan 09 22:01:39 2012 +0100
@@ -2015,7 +2015,8 @@
   const int BUFFER_SIZE = 1024;
   char path[BUFFER_SIZE];
 
-  sprintf(path, "%s/%s/bin", graal_dir, project);
+  const char fileSep = *os::file_separator();
+  sprintf(path, "%s%c%s%cbin", graal_dir, fileSep, project, fileSep);
   DIR* dir = os::opendir(path);
   if (dir == NULL) {
     jio_fprintf(defaultStream::output_stream(), "Error while starting Graal VM: The Graal class directory %s could not be opened.\n", path);
@@ -2031,8 +2032,14 @@
 static bool find_graal_dir(char* graal_dir) {
   strcpy(graal_dir, Arguments::get_java_home());
   char* end = graal_dir + strlen(graal_dir);
+  const char fileSep = *os::file_separator();
   while (end != graal_dir) {
-    strcat(graal_dir, "/graal");
+    if (fileSep == '/') 
+      strcat(graal_dir, "/graal");
+    else {
+      assert(fileSep == '\\', "unexpected separator char");
+      strcat(graal_dir, "\\graal");
+    }
     DIR* dir = os::opendir(graal_dir);
     if (dir != NULL) {
       os::closedir(dir);
@@ -2040,7 +2047,7 @@
     }
     *end = 0;
     while (end != graal_dir) {
-      if (*end == '/') {
+      if (*end == fileSep) {
         *end = 0;
         break;
       }