annotate pytools/gl.py @ 3713:d6a0c46a73b2

Add all DaCapo benchmarks, allow batch execution of all DaCapo benchmarks, add -d flag to start HotSpot under the debugger
author Christian Wimmer <christian.wimmer@oracle.com>
date Tue, 13 Dec 2011 21:16:50 -0800
parents 4a76e44544d9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 #!/usr/bin/python
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 #
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 # gl.py - shell interface for Graal source code
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 #
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 # ----------------------------------------------------------------------------------------------------
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 #
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 # Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 #
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 # This code is free software; you can redistribute it and/or modify it
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 # under the terms of the GNU General Public License version 2 only, as
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 # published by the Free Software Foundation.
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 #
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 # This code is distributed in the hope that it will be useful, but WITHOUT
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 # version 2 for more details (a copy is included in the LICENSE file that
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 # accompanied this code).
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 #
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 # You should have received a copy of the GNU General Public License version
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 # 2 along with this work; if not, write to the Free Software Foundation,
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 #
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 # or visit www.oracle.com if you need additional information or have any
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26 # questions.
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27 #
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28 # ----------------------------------------------------------------------------------------------------
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29 #
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 # A launcher for Graal executables and tools.
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 #
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 import subprocess
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 from threading import Thread
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 from argparse import ArgumentParser, REMAINDER
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 from os.path import join, dirname, abspath, exists, isfile, isdir
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 import commands
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38 import types
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 import sys
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 import os
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 class Env(ArgumentParser):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44 # Override parent to append the list of available commands
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
45 def format_help(self):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 msg = ArgumentParser.format_help(self) + '\navailable commands:\n\n'
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 for cmd in sorted(commands.table.iterkeys()):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 c, _ = commands.table[cmd][:2]
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 doc = c.__doc__
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 if doc is None:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51 doc = ''
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 msg += ' {0:<20} {1}\n'.format(cmd, doc.split('\n', 1)[0])
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
53 return msg + '\n'
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
54
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55 def __init__(self):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
56 self.dacapo = os.getenv('DACAPO')
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
57 self.jdk7 = os.getenv('JDK7')
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
58 self.maxine = os.getenv('MAXINE')
3691
b054dd61bfe1 Made gl script able to import and use the mx script.
Doug Simon <doug.simon@oracle.com>
parents: 3628
diff changeset
59 self._mx = None
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61 ArgumentParser.__init__(self, prog='gl')
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63 self.add_argument('-v', action='store_true', dest='verbose', help='enable verbose output')
3713
d6a0c46a73b2 Add all DaCapo benchmarks, allow batch execution of all DaCapo benchmarks, add -d flag to start HotSpot under the debugger
Christian Wimmer <christian.wimmer@oracle.com>
parents: 3692
diff changeset
64 self.add_argument('-d', action='store_true', dest='java_dbg', help='make Java processes wait on port 8000 for a debugger')
3624
e81927755129 Removed targetting of JDK7G by gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3623
diff changeset
65 self.add_argument('--dacapo', help='path to DaCapo 9.12 jar file', metavar='<path>')
e81927755129 Removed targetting of JDK7G by gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3623
diff changeset
66 self.add_argument('--jdk7', help='JDK7 in which the GraalVM will be installed', metavar='<path>')
e81927755129 Removed targetting of JDK7G by gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3623
diff changeset
67 self.add_argument('-M', dest='maxine', help='path to Maxine code base', metavar='<path>')
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
68
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
69 def parse_cmd_line(self, configFile):
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
70
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71 self.add_argument('commandAndArgs', nargs=REMAINDER, metavar='command args...')
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
72
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
73 self.parse_args(namespace=self)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
74
3627
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
75 if self.jdk7 is None:
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
76 self.abort('JDK7 is required. Use --jdk7 option or set JDK7 environment variable (in ' + configFile + ')')
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
77
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
78 if not isdir(self.jdk7):
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
79 self.abort('Specified JDK7 path is not a directory: ' + self.jdk7)
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
80
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
81 self.graal_home = dirname(abspath(dirname(sys.argv[0])))
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
82
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
83 def load_config_file(self, configFile):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
84 """ adds attributes to this object from a file containing key=value lines """
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
85 if exists(configFile):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
86 with open(configFile) as f:
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
87 #self.log('[loading vars from ' + configFile + ']')
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
88 for line in f:
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
89 if not line.startswith('#'):
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
90 kv = line.split('=', 1)
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
91 if len(kv) == 2:
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
92 k = kv[0].strip().lower()
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
93 setattr(self, k, os.path.expandvars(kv[1].strip()))
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
94
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
95 def get_os(self):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
96 if sys.platform.startswith('darwin'):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
97 return 'darwin'
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
98 elif sys.platform.startswith('linux'):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
99 return 'linux'
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
100 elif sys.platform.startswith('sunos'):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
101 return 'solaris'
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
102 elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
103 return 'windows'
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
104 else:
3627
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
105 self.abort('Supported operating system could not be derived from ' + sys.platform)
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
106
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
107
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
108 def exe(self, name):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
109 if self.get_os() == 'windows':
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
110 return name + '.exe'
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
111 return name
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
112
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
113 def run_dacapo(self, args):
3692
4a76e44544d9 Made the safeadd and vectorlib examples runnable from the gl script:
Doug Simon <doug.simon@oracle.com>
parents: 3691
diff changeset
114 if self.dacapo is None:
4a76e44544d9 Made the safeadd and vectorlib examples runnable from the gl script:
Doug Simon <doug.simon@oracle.com>
parents: 3691
diff changeset
115 self.abort('Need to specify DaCapo jar with --dacapo option or DACAPO environment variable')
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
116 if not isfile(self.dacapo) or not self.dacapo.endswith('.jar'):
3627
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
117 self.abort('Specified DaCapo jar file does not exist or is not a jar file: ' + self.dacapo)
3713
d6a0c46a73b2 Add all DaCapo benchmarks, allow batch execution of all DaCapo benchmarks, add -d flag to start HotSpot under the debugger
Christian Wimmer <christian.wimmer@oracle.com>
parents: 3692
diff changeset
118 return self.run_vm(['-Xms1g', '-Xmx2g', '-esa', '-cp', self.dacapo] + args)
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
119
3692
4a76e44544d9 Made the safeadd and vectorlib examples runnable from the gl script:
Doug Simon <doug.simon@oracle.com>
parents: 3691
diff changeset
120 def run_vm(self, args, vm='-graal'):
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
121 if self.maxine is None:
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
122 configFile = join(dirname(sys.argv[0]), 'glrc')
3627
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
123 self.abort('Path to Maxine code base must be specified with -M option or MAXINE environment variable (in ' + configFile + ')')
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
124 if not exists(join(self.maxine, 'com.oracle.max.graal.hotspot', 'bin', 'com', 'oracle', 'max', 'graal', 'hotspot', 'VMEntriesNative.class')):
3627
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
125 self.abort('Maxine code base path specified -M option or MAXINE environment variable does not contain com.oracle.max.graal.hotspot/bin/com/oracle/max/graal/hotspot/VMEntriesNative.class: ' + self.maxine)
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
126
3713
d6a0c46a73b2 Add all DaCapo benchmarks, allow batch execution of all DaCapo benchmarks, add -d flag to start HotSpot under the debugger
Christian Wimmer <christian.wimmer@oracle.com>
parents: 3692
diff changeset
127 if self.java_dbg:
d6a0c46a73b2 Add all DaCapo benchmarks, allow batch execution of all DaCapo benchmarks, add -d flag to start HotSpot under the debugger
Christian Wimmer <christian.wimmer@oracle.com>
parents: 3692
diff changeset
128 args = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'] + args
d6a0c46a73b2 Add all DaCapo benchmarks, allow batch execution of all DaCapo benchmarks, add -d flag to start HotSpot under the debugger
Christian Wimmer <christian.wimmer@oracle.com>
parents: 3692
diff changeset
129
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
130 os.environ['MAXINE'] = self.maxine
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
131 exe = join(self.jdk7, 'bin', self.exe('java'))
3692
4a76e44544d9 Made the safeadd and vectorlib examples runnable from the gl script:
Doug Simon <doug.simon@oracle.com>
parents: 3691
diff changeset
132 return self.run([exe, vm] + args)
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
133
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
134 def run(self, args, nonZeroIsFatal=True, out=None, err=None, cwd=None):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
135 """
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
136
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
137 Run a command in a subprocess, wait for it to complete and return the exit status of the process.
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
138 If the exit status is non-zero and `nonZeroIsFatal` is true, then the program is exited with
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
139 the same exit status.
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
140 Each line of the standard output and error streams of the subprocess are redirected to the
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
141 provided out and err functions if they are not None.
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
142
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143 """
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
144
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
145 assert isinstance(args, types.ListType), "'args' must be a list: " + str(args)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
146 for arg in args:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
147 if not isinstance(arg, types.StringTypes):
3627
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
148 self.abort('argument is not a string: ' + str(arg))
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
149
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
150 if self.verbose:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
151 self.log(' '.join(args))
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
152
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
153 try:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
154 if out is None and err is None:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
155 retcode = subprocess.call(args, cwd=cwd)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
156 else:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
157 def redirect(stream, f):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
158 for line in iter(stream.readline, ''):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
159 f(line)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
160 stream.close()
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
161 p = subprocess.Popen(args, stdout=None if out is None else subprocess.PIPE, stderr=None if err is None else subprocess.PIPE)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
162 if out is not None:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
163 t = Thread(target=redirect, args=(p.stdout, out))
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
164 t.daemon = True # thread dies with the program
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
165 t.start()
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
166 if err is not None:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
167 t = Thread(target=redirect, args=(p.stderr, err))
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
168 t.daemon = True # thread dies with the program
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
169 t.start()
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
170 retcode = p.wait()
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
171 except OSError as e:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
172 self.log('Error executing \'' + ' '.join(args) + '\': ' + str(e))
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
173 if self.verbose:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
174 raise e
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
175 self.abort(e.errno)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
176
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
177
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
178 if retcode and nonZeroIsFatal:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
179 if self.verbose:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
180 raise subprocess.CalledProcessError(retcode, ' '.join(args))
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
181 self.abort(retcode)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
182
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
183 return retcode
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
184
3628
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
185 def gmake_cmd(self):
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
186 for a in ['make', 'gmake', 'gnumake']:
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
187 try:
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
188 output = subprocess.check_output([a, '--version'])
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
189 if 'GNU' in output:
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
190 return a;
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
191 except:
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
192 pass
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
193 self.abort('Could not find a GNU make executable on the current path.')
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
194
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
195 def log(self, msg=None):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
196 if msg is None:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
197 print
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
198 else:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
199 print msg
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
200
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
201 def abort(self, code):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
202 """ raises a SystemExit exception with the provided exit code """
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
203 raise SystemExit(code)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
204
3691
b054dd61bfe1 Made gl script able to import and use the mx script.
Doug Simon <doug.simon@oracle.com>
parents: 3628
diff changeset
205 def mx(self):
b054dd61bfe1 Made gl script able to import and use the mx script.
Doug Simon <doug.simon@oracle.com>
parents: 3628
diff changeset
206 if (self._mx is None):
b054dd61bfe1 Made gl script able to import and use the mx script.
Doug Simon <doug.simon@oracle.com>
parents: 3628
diff changeset
207 p = join(self.maxine, 'com.oracle.max.shell')
b054dd61bfe1 Made gl script able to import and use the mx script.
Doug Simon <doug.simon@oracle.com>
parents: 3628
diff changeset
208 sys.path.insert(0, p)
b054dd61bfe1 Made gl script able to import and use the mx script.
Doug Simon <doug.simon@oracle.com>
parents: 3628
diff changeset
209 import mx
b054dd61bfe1 Made gl script able to import and use the mx script.
Doug Simon <doug.simon@oracle.com>
parents: 3628
diff changeset
210 self._mx = mx.Env()
b054dd61bfe1 Made gl script able to import and use the mx script.
Doug Simon <doug.simon@oracle.com>
parents: 3628
diff changeset
211 self._mx.maxine_home = self.maxine
b054dd61bfe1 Made gl script able to import and use the mx script.
Doug Simon <doug.simon@oracle.com>
parents: 3628
diff changeset
212 self._mx.parse_cmd_line([])
b054dd61bfe1 Made gl script able to import and use the mx script.
Doug Simon <doug.simon@oracle.com>
parents: 3628
diff changeset
213 return self._mx
b054dd61bfe1 Made gl script able to import and use the mx script.
Doug Simon <doug.simon@oracle.com>
parents: 3628
diff changeset
214
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
215 def main(env):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
216 configFile = join(dirname(sys.argv[0]), 'glrc')
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
217 env.load_config_file(configFile)
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
218 env.parse_cmd_line(configFile)
3607
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
219
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
220 if len(env.commandAndArgs) == 0:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
221 env.print_help()
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
222 return
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
223
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
224 env.command = env.commandAndArgs[0]
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
225 env.command_args = env.commandAndArgs[1:]
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
226
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
227 if not commands.table.has_key(env.command):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
228 env.error('unknown command "' + env.command + '"')
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
229
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
230 c, _ = commands.table[env.command][:2]
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
231 try:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
232 retcode = c(env, env.command_args)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
233 if retcode is not None and retcode != 0:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
234 env.abort(retcode)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
235 except KeyboardInterrupt:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
236 env.abort(1)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
237
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
238 #This idiom means the below code only runs when executed from command line
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
239 if __name__ == '__main__':
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
240 main(Env())