annotate pytools/gl.py @ 3612:ed3ac862d22d

IdealGraphVisualizer: make Graal graph-to-text converter work again after last commit by copying properties that have the same value in the two input graphs groups to the newly created diff group's properties.
author Peter Hofer <peter.hofer@jku.at>
date Wed, 02 Nov 2011 17:27:31 +0100
parents de066dcbf607
children 3b2ab8970aa4
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')
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59 self.maxine_home = os.getenv('MAXINE')
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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>')
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 self.add_argument('-M', '--maxine', dest='maxine_home', help='path to Maxine code base', 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
68
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 def parse_cmd_line(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
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
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
75 if not isdir(self.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
76 self.log('JDK7 is required. Use --jdk7 option or set JDK7 environment variable')
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 if not isdir(self.jdk7g):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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.log('JDK7G is required. Use --jdk7g option or set JDK7G environment variable')
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
89 self.log('[loading vars from ' + 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
90 for line in 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
91 kv = line.split('=', 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
92 if len(kv) == 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
93 k = kv[0].strip().lower()
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 setattr(self, k, os.path.expandvars(kv[1].strip()))
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
97 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
98 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
99 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
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
111 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
112 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
113 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
114
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
116 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
117 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
118 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
119 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
120
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 def run_vm(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
122 if self.maxine_home 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
123 self.log('Path to Maxine code base must be specified with -M option of MAXINE environment variable')
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
124 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
125 if not exists(join(self.maxine_home, 'com.oracle.max.graal.hotspot', 'bin', 'com', 'oracle', 'max', 'graal', 'hotspot', 'VMEntriesNative.class')):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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.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_home)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
128
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 os.environ['MAXINE'] = self.maxine_home
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
131 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
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 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
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
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
137 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
138 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
139 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
140 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
141
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
142 """
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
144 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
145 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
146 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
147 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
148 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
149
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
150 if self.verbose:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
151 self.log(' '.join(args))
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
152
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
153 try:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
154 if out is None and err is None:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
155 retcode = subprocess.call(args, cwd=cwd)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
156 else:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
157 def redirect(stream, f):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
158 for line in iter(stream.readline, ''):
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
159 f(line)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
160 stream.close()
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
161 p = subprocess.Popen(args, stdout=None if out is None else subprocess.PIPE, stderr=None if err is None else subprocess.PIPE)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
162 if out is not None:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
163 t = Thread(target=redirect, args=(p.stdout, out))
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
164 t.daemon = True # thread dies with the program
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
165 t.start()
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
166 if err is not None:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
167 t = Thread(target=redirect, args=(p.stderr, err))
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
168 t.daemon = True # thread dies with the program
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
169 t.start()
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
170 retcode = p.wait()
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
171 except OSError as e:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
172 self.log('Error executing \'' + ' '.join(args) + '\': ' + str(e))
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
173 if self.verbose:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
174 raise e
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
175 self.abort(e.errno)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
176
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
177
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
178 if retcode and nonZeroIsFatal:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
179 if self.verbose:
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
180 raise subprocess.CalledProcessError(retcode, ' '.join(args))
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
181 self.abort(retcode)
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
182
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
183 return retcode
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
184
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
187 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
188 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
189 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
190 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
191
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
193 """ 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
194 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
195
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
197 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
198 env.load_config_file(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
199 env.parse_cmd_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
200
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.sh scripts in the top level Graal directory and is where new commands should go.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
201 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
202 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
203 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
204
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
206 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
207
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
209 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
210
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 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
212 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
213 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
214 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
215 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
216 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
217 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
218
de066dcbf607 Added Python scripts in new 'shell' project. The shell/commands.py script should replace all the existing run*.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 #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
220 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
221 main(Env())