Mercurial > hg > truffle
comparison pytools/commands.py @ 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.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 31 Oct 2011 21:06:04 +0100 |
parents | |
children | 3b2ab8970aa4 |
comparison
equal
deleted
inserted
replaced
3606:f2fd47582524 | 3607:de066dcbf607 |
---|---|
1 # | |
2 # commands.py - the default commands available to gl.py | |
3 # | |
4 # ---------------------------------------------------------------------------------------------------- | |
5 # | |
6 # Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. | |
7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 # | |
9 # This code is free software; you can redistribute it and/or modify it | |
10 # under the terms of the GNU General Public License version 2 only, as | |
11 # published by the Free Software Foundation. | |
12 # | |
13 # This code is distributed in the hope that it will be useful, but WITHOUT | |
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 # version 2 for more details (a copy is included in the LICENSE file that | |
17 # accompanied this code). | |
18 # | |
19 # You should have received a copy of the GNU General Public License version | |
20 # 2 along with this work; if not, write to the Free Software Foundation, | |
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
22 # | |
23 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
24 # or visit www.oracle.com if you need additional information or have any | |
25 # questions. | |
26 # | |
27 # ---------------------------------------------------------------------------------------------------- | |
28 | |
29 import os | |
30 from os.path import join, exists | |
31 from collections import Callable | |
32 | |
33 def clean(env, args): | |
34 """cleans the Graal+HotSpot source tree""" | |
35 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='16') | |
36 env.run(['gmake', 'clean'], cwd=join(env.graal_home, 'make')) | |
37 | |
38 def bootstrap(env, args): | |
39 return env.run_vm(args + ['-version']) | |
40 | |
41 def avrora(env, args): | |
42 return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'avrora']) | |
43 | |
44 def batik(env, args): | |
45 return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'batik']) | |
46 | |
47 def eclipse(env, args): | |
48 return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'eclipse']) | |
49 | |
50 def fop(env, args): | |
51 return env.run_dacapo(args + ['Harness', '--preserve', '-n', '100', 'fop']) | |
52 | |
53 def h2(env, args): | |
54 return env.run_dacapo(args + ['Harness', '--preserve', '-n', '10', 'h2']) | |
55 | |
56 def jython(env, args): | |
57 return env.run_dacapo(args + ['Harness', '--preserve', '-n', '10', 'jython']) | |
58 | |
59 def lusearch(env, args): | |
60 return env.run_dacapo(args + ['Harness', '--preserve', '-n', '5', 'lusearch']) | |
61 | |
62 def pmd(env, args): | |
63 return env.run_dacapo(args + ['Harness', '--preserve', '-n', '10', 'pmd']) | |
64 | |
65 def tradebeans(env, args): | |
66 return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'tradebeans']) | |
67 | |
68 def xalan(env, args): | |
69 return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'xalan']) | |
70 | |
71 def tests(env, args): | |
72 """run a selection of the Maxine JTT tests in Graal""" | |
73 | |
74 def jtt(name): | |
75 return join(env.maxine_home, 'com.oracle.max.vm', 'test', 'jtt', name) | |
76 | |
77 return env.run_vm(args + ['-ea', '-esa', '-Xcomp', '-XX:+PrintCompilation', '-XX:CompileOnly=jtt'] + args + | |
78 ['-Xbootclasspath/p:' + join(env.maxine_home, 'com.oracle.max.vm', 'bin'), | |
79 '-Xbootclasspath/p:' + join(env.maxine_home, 'com.oracle.max.base', 'bin'), | |
80 'test.com.sun.max.vm.compiler.JavaTester', | |
81 '-verbose=1', '-gen-run-scheme=false', '-run-scheme-package=all', | |
82 jtt('bytecode'), | |
83 jtt('except'), | |
84 jtt('jdk'), | |
85 jtt('hotpath'), | |
86 jtt('jdk'), | |
87 jtt('lang'), | |
88 jtt('loop'), | |
89 jtt('micro'), | |
90 jtt('optimize'), | |
91 jtt('reflect'), | |
92 jtt('threads'), | |
93 jtt('hotspot')]) | |
94 | |
95 def help_(env, args): | |
96 """show help for a given command | |
97 | |
98 With no arguments, print a list of commands and short help for each command. | |
99 | |
100 Given a command name, print help for that command.""" | |
101 if len(args) == 0: | |
102 env.print_help() | |
103 return | |
104 | |
105 name = args[0] | |
106 if not table.has_key(name): | |
107 env.error('unknown command: ' + name) | |
108 | |
109 value = table[name] | |
110 (func, usage) = value[:2] | |
111 doc = func.__doc__ | |
112 if len(value) > 2: | |
113 docArgs = value[2:] | |
114 fmtArgs = [] | |
115 for d in docArgs: | |
116 if isinstance(d, Callable): | |
117 fmtArgs += [d(env)] | |
118 else: | |
119 fmtArgs += [str(d)] | |
120 doc = doc.format(*fmtArgs) | |
121 print 'gl {0} {1}\n\n{2}\n'.format(name, usage, doc) | |
122 | |
123 def make(env, args): | |
124 """builds the Graal+HotSpot binary""" | |
125 | |
126 | |
127 jvmCfg = join(env.jdk7, 'jre', 'lib', 'amd64', 'jvm.cfg') | |
128 found = False | |
129 with open(jvmCfg) as f: | |
130 for line in f: | |
131 if '-graal KNOWN' in line: | |
132 found = True | |
133 break | |
134 | |
135 if not found: | |
136 env.log('Appending "-graal KNOWN" to ' + jvmCfg) | |
137 with open(jvmCfg, 'a') as f: | |
138 f.write('-graal KNOWN\n') | |
139 | |
140 if env.get_os() != 'windows': | |
141 javaLink = join(env.graal_home, 'graal', 'hotspot', 'java') | |
142 if not exists(javaLink): | |
143 javaExe = join(env.jdk7, 'jre', 'bin', 'java') | |
144 env.log('Creating link: ' + javaLink + ' -> ' + javaExe) | |
145 os.symlink(javaExe, javaLink) | |
146 | |
147 graalVmDir = join(env.jdk7, 'jre', 'lib', 'amd64', 'graal') | |
148 if not exists(graalVmDir): | |
149 env.log('Creating Graal directory in JDK7: ' + graalVmDir) | |
150 os.makedirs(graalVmDir) | |
151 | |
152 graalVmDbgDir = join(env.jdk7g, 'jre', 'lib', 'amd64', 'graal') | |
153 if not exists(graalVmDbgDir): | |
154 env.log('Creating Graal directory in JDK7G: ' + graalVmDbgDir) | |
155 os.makedirs(graalVmDbgDir) | |
156 | |
157 | |
158 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='4', ALT_BOOTDIR=env.jdk7g, INSTALL='y') | |
159 env.run(['gmake', 'jvmggraal'], cwd=join(env.graal_home, 'make')) | |
160 | |
161 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='4', ALT_BOOTDIR=env.jdk7, INSTALL='y') | |
162 env.run(['gmake', 'productgraal'], cwd=join(env.graal_home, 'make')) | |
163 | |
164 # Table of commands in alphabetical order. | |
165 # Keys are command names, value are lists: [<function>, <usage msg>, <format args to doc string of function>...] | |
166 # If any of the format args are instances of Callable, then they are called with an 'env' are before being | |
167 # used in the call to str.format(). | |
168 # Extensions should update this table directly | |
169 table = { | |
170 'avrora': [avrora, ''], | |
171 'batik': [batik, ''], | |
172 'bootstrap': [bootstrap, ''], | |
173 'clean': [clean, ''], | |
174 'fop': [fop, ''], | |
175 'h2': [h2, ''], | |
176 'jython': [jython, ''], | |
177 'lusearch': [lusearch, ''], | |
178 'pmd': [pmd, ''], | |
179 'tradebeans': [tradebeans, ''], | |
180 'tests': [tests, ''], | |
181 'help': [help_, '[command]'], | |
182 'make': [make, ''], | |
183 'xalan': [xalan, ''], | |
184 } |