annotate pytools/gl.py @ 3623:3b2ab8970aa4

Improved gl.py script.
author Doug Simon <doug.simon@oracle.com>
date Wed, 09 Nov 2011 16:02:46 +0100
parents de066dcbf607
children e81927755129
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')
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
58 self.jdk7g = os.getenv('JDK7G')
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
59 self.maxine = os.getenv('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
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')
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
64 self.add_argument('--dacapo', help='path to DaCapo 91.12 jar file')
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
65 self.add_argument('--jdk7', help='JDK7 installation in which the GraalVM binary is installed', metavar='<path>')
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
66 self.add_argument('--jdk7g', help='JDK7G installation in which the GraalVM binary is installed', metavar='<path>')
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
67 self.add_argument('-M', '--maxine', 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
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
75 if self.jdk7 is None or not isdir(self.jdk7):
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
76 self.log('JDK7 is required. Use --jdk7 option or set JDK7 environment variable (in ' + 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
77 self.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
78
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
79 if self.jdk7g is None or not isdir(self.jdk7g):
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
80 self.log('JDK7G is required. Use --jdk7g option or set JDK7G environment variable (in ' + 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
81 self.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
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 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
84
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 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
86 """ 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
87 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
88 with open(configFile) as f:
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
89 #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
90 for line in f:
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
91 if not line.startswith('#'):
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
92 kv = line.split('=', 1)
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
93 if len(kv) == 2:
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
94 k = kv[0].strip().lower()
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
95 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
96
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 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
98 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
99 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
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107 print 'Supported operating system could not be derived from', sys.platform
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 self.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
109
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
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 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
112 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
113 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
114 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
115
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 def run_dacapo(self, 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
117 if not isfile(self.dacapo) or not self.dacapo.endswith('.jar'):
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
118 self.log('Specified DaCapo jar file does not exist or is not a jar file: ' + self.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
119 self.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
120 return self.run_vm(['-Xms1g', '-Xmx2g', '-esa', '-XX:-GraalBailoutIsFatal', '-G:-QuietBailout', '-cp', self.dacapo] + 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
121
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
122 def run_vm(self, args):
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
123 if self.maxine is None:
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
124 configFile = join(dirname(sys.argv[0]), 'glrc')
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
125 self.log('Path to Maxine code base must be specified with -M option or MAXINE environment variable (in ' + 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
126 self.abort(1)
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
127 if not exists(join(self.maxine, 'com.oracle.max.graal.hotspot', 'bin', 'com', 'oracle', 'max', 'graal', 'hotspot', 'VMEntriesNative.class')):
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
128 self.log('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
129 self.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
130
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
131 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
132 exe = join(self.jdk7, 'bin', self.exe('java'))
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 return self.run([exe, '-graal'] + 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
134
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 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
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
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 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
139 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
140 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
141 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
142 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
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
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 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
147 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
148 if not isinstance(arg, types.StringTypes):
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 self.log('argument is not a string: ' + str(arg))
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 self.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
151
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 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
153 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
154
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 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165 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
166 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
167 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
168 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
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176 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
177 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
178
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
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 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
181 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
182 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
183 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
184
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
185 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
186
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
187
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
188 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
189 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
190 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
191 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
192 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
193
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 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
195 """ 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
196 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
197
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 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
199 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
200 env.load_config_file(configFile)
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
201 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
202
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 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
204 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
205 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
206
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
207 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
208 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
209
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
210 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
211 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
212
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
213 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
214 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
215 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
216 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
217 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
218 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
219 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
220
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 #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
222 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
223 main(Env())