annotate pytools/gl.py @ 3692:4a76e44544d9

Made the safeadd and vectorlib examples runnable from the gl script: gl safeadd gl vectorlib Consolidated individual DaCapo commands into one 'dacapo' command.
author Doug Simon <doug.simon@oracle.com>
date Thu, 24 Nov 2011 13:19:40 +0100
parents b054dd61bfe1
children d6a0c46a73b2
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')
3624
e81927755129 Removed targetting of JDK7G by gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3623
diff changeset
64 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
65 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
66 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
67
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
68 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
69
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
71
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
73
3627
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
74 if self.jdk7 is None:
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
75 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
76
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
77 if not isdir(self.jdk7):
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
78 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
79
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
81
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
83 """ 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
84 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
85 with open(configFile) as f:
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
86 #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
87 for line in f:
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
88 if not line.startswith('#'):
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
89 kv = line.split('=', 1)
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
90 if len(kv) == 2:
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
91 k = kv[0].strip().lower()
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
92 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
93
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103 else:
3627
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
104 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
105
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
108 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
109 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
110 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
111
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
113 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
114 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
115 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
116 self.abort('Specified DaCapo jar file does not exist or is not a jar file: ' + self.dacapo)
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
117 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
118
3692
4a76e44544d9 Made the safeadd and vectorlib examples runnable from the gl script:
Doug Simon <doug.simon@oracle.com>
parents: 3691
diff changeset
119 def run_vm(self, args, vm='-graal'):
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
120 if self.maxine is None:
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
121 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
122 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
123 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
124 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
125
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
126 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
127 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
128 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
129
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
131 """
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
134 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
135 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
136 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
137 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
138
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 """
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
142 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
143 if not isinstance(arg, types.StringTypes):
3627
c773cc740d4a Improved error messages in gl.py.
Doug Simon <doug.simon@oracle.com>
parents: 3624
diff changeset
144 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
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 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
147 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
148
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 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
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 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
167 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
168 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
169 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
170 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
171 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
172
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
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 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
177 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
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 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
180
3628
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
181 def gmake_cmd(self):
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
182 for a in ['make', 'gmake', 'gnumake']:
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
183 try:
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
184 output = subprocess.check_output([a, '--version'])
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
185 if 'GNU' in output:
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
186 return a;
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
187 except:
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
188 pass
61f10abeb25a Removed more vestiges of JDK7G build support.
Doug Simon <doug.simon@oracle.com>
parents: 3627
diff changeset
189 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
190
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
192 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
193 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
194 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
195 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
196
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
198 """ 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
199 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
200
3691
b054dd61bfe1 Made gl script able to import and use the mx script.
Doug Simon <doug.simon@oracle.com>
parents: 3628
diff changeset
201 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
202 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
203 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
204 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
205 import mx
b054dd61bfe1 Made gl script able to import and use the mx script.
Doug Simon <doug.simon@oracle.com>
parents: 3628
diff changeset
206 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
207 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
208 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
209 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
210
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
211 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
212 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
213 env.load_config_file(configFile)
3623
3b2ab8970aa4 Improved gl.py script.
Doug Simon <doug.simon@oracle.com>
parents: 3607
diff changeset
214 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
215
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
217 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
218 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
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 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
221 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
222
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
224 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
225
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
227 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
228 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
229 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
230 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
231 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
232 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
233
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 #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
235 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
236 main(Env())