Mercurial > hg > truffle
annotate mx/commands.py @ 3730:4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 16 Dec 2011 21:56:00 +0100 |
parents | 7c5524a4e86e |
children | 3e2e8b8abdaf |
rev | line source |
---|---|
3718 | 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 | |
3730
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
29 import os, sys, shutil, tarfile |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
30 from os.path import join, exists, dirname, isfile, isdir |
3718 | 31 |
32 graal_home = dirname(dirname(__file__)) | |
33 | |
34 def clean(env, args): | |
35 """cleans the GraalVM source tree""" | |
36 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='16') | |
37 env.run([env.gmake_cmd(), 'clean'], cwd=join(graal_home, 'make')) | |
38 | |
39 def example(env, args): | |
40 """run some or all Graal examples""" | |
41 examples = { | |
42 'safeadd': ['com.oracle.max.graal.examples.safeadd', 'com.oracle.max.graal.examples.safeadd.Main'], | |
43 'vectorlib': ['com.oracle.max.graal.examples.vectorlib', 'com.oracle.max.graal.examples.vectorlib.Main'], | |
44 } | |
45 | |
46 def run_example(env, verbose, project, mainClass): | |
47 cp = env.pdb.classpath(project) | |
48 sharedArgs = ['-Xcomp', '-XX:CompileOnly=Main', mainClass] | |
49 | |
50 res = [] | |
51 env.log("=== Server VM ===") | |
52 printArg = '-XX:+PrintCompilation' if verbose else '-XX:-PrintCompilation' | |
53 res.append(vm(env, ['-cp', cp, printArg] + sharedArgs, vm="-server")) | |
54 env.log("=== Graal VM ===") | |
55 printArg = '-G:+PrintCompilation' if verbose else '-G:-PrintCompilation' | |
56 res.append(vm(env, ['-cp', cp, printArg, '-G:-Extend', '-G:-Inline'] + sharedArgs)) | |
57 env.log("=== Graal VM with extensions ===") | |
58 res.append(vm(env, ['-cp', cp, printArg, '-G:+Extend', '-G:-Inline'] + sharedArgs)) | |
59 | |
60 if len([x for x in res if x != 0]) != 0: | |
61 return 1 | |
62 return 0 | |
63 | |
64 verbose = False | |
65 if '-v' in args: | |
66 verbose = True | |
67 args = [a for a in args if a != '-v'] | |
68 | |
69 if len(args) == 0: | |
70 args = examples.keys() | |
71 for a in args: | |
72 config = examples.get(a) | |
73 if config is None: | |
74 env.log('unknown example: ' + a + ' {available examples = ' + str(examples.keys()) + '}') | |
75 else: | |
76 env.log('--------- ' + a + ' ------------') | |
77 project, mainClass = config | |
78 run_example(env, verbose, project, mainClass) | |
79 | |
80 def dacapo(env, args): | |
3722
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
81 """run one or all DaCapo benchmarks""" |
3718 | 82 |
83 benchmarks = { | |
84 'avrora': ['-n', '5'], | |
85 'batik': ['-n', '5'], | |
86 'eclipse': ['-n', '5'], | |
87 'fop': ['-n', '5'], | |
88 'h2': ['-n', '5'], | |
89 'jython': ['-n', '5'], | |
90 'luindex': ['-n', '5'], | |
91 'lusearch': ['-n', '5'], | |
92 'pmd': ['-n', '5'], | |
93 'sunflow': ['-n', '5'], | |
94 'tomcat': ['-n', '5'], | |
95 'tradebeans': ['-n', '5'], | |
96 'tradesoap': ['-n', '5'], | |
97 'xalan': ['-n', '5'], | |
98 } | |
99 | |
3722
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
100 dacapo = env.check_get_env('DACAPO_CP') |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
101 if not isfile(dacapo) or not dacapo.endswith('.jar'): |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
102 env.abort('Specified DaCapo jar file does not exist or is not a jar file: ' + dacapo) |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
103 |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
104 vmOpts = ['-Xms1g', '-Xmx2g', '-esa', '-cp', dacapo] |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
105 |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
106 runs = dict() |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
107 while len(args) != 0 and not args[0].startswith('-'): |
3718 | 108 bm = args[0] |
3722
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
109 del args[0] |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
110 config = benchmarks.get(bm) |
3718 | 111 if (config is None): |
112 env.abort('unknown benchmark: ' + bm + '\nselect one of: ' + str(benchmarks.keys())) | |
3722
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
113 runs[bm] = config |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
114 |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
115 if len(runs) == 0: |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
116 runs = benchmarks |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
117 |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
118 vmOpts += args |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
119 for bm in runs: |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
120 config = benchmarks.get(bm) |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
121 vm(env, vmOpts + ['Harness'] + config + [bm]) |
3718 | 122 |
123 def tests(env, args): | |
124 """run a selection of the Maxine JTT tests in Graal""" | |
125 | |
126 maxine = env.check_get_env('MAXINE_HOME') | |
127 def jtt(name): | |
128 return join(maxine, 'com.oracle.max.vm', 'test', 'jtt', name) | |
129 | |
130 return vm(env, ['-ea', '-esa', '-Xcomp', '-XX:+PrintCompilation', '-XX:CompileOnly=jtt'] + args + | |
131 ['-Xbootclasspath/p:' + join(maxine, 'com.oracle.max.vm', 'bin'), | |
132 '-Xbootclasspath/p:' + join(maxine, 'com.oracle.max.base', 'bin'), | |
133 'test.com.sun.max.vm.compiler.JavaTester', | |
134 '-verbose=1', '-gen-run-scheme=false', '-run-scheme-package=all', | |
135 jtt('bytecode'), | |
136 jtt('except'), | |
137 jtt('jdk'), | |
138 jtt('hotpath'), | |
139 jtt('jdk'), | |
140 jtt('lang'), | |
141 jtt('loop'), | |
142 jtt('micro'), | |
143 jtt('optimize'), | |
144 jtt('reflect'), | |
145 jtt('threads'), | |
146 jtt('hotspot')]) | |
147 | |
3730
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
148 |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
149 def _download_and_extract_targz_jdk7(env, url, dst): |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
150 assert url.endswith('.tar.gz') |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
151 dl = join(graal_home, 'jdk7.tar.gz') |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
152 try: |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
153 if not exists(dl): |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
154 env.download(dl, [url]) |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
155 tmp = join(graal_home, 'tmp') |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
156 if not exists(tmp): |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
157 os.mkdir(tmp) |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
158 with tarfile.open(dl, mode='r:gz') as f: |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
159 env.log('Extracting ' + dl) |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
160 f.extractall(path=tmp) |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
161 jdk = os.listdir(tmp)[0] |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
162 shutil.move(join(tmp, jdk), dst) |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
163 os.rmdir(tmp) |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
164 os.remove(dl) |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
165 except SystemExit: |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
166 env.abort('Could not download JDK7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html.\n' + |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
167 'Please do this manually and install it at ' + dst + ' or set the JDK7 environment variable to the install location.') |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
168 |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
169 |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
170 def _jdk7(env, build='product', create=False): |
3730
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
171 jdk7 = os.environ.get('JDK7') |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
172 if jdk7 is None: |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
173 jdk7 = join(graal_home, 'jdk7') |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
174 if not exists(jdk7): |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
175 # Try to download it |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
176 if env.os == 'linux': |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
177 _download_and_extract_targz_jdk7(env, 'http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-x64.tar.gz', jdk7) |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
178 else: |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
179 env.abort('Download JDK7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html\n' + |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
180 'and install it at ' + jdk7 + ' or set the JDK7 environment variable to the JDK7 install location.') |
4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents:
3722
diff
changeset
|
181 |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
182 jre = join(jdk7, 'jre') |
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
183 if not exists(jre) or not isdir(jre): |
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
184 env.abort(jdk7 + ' does not appear to be a valid JDK directory ("jre" sub-directory is missing)') |
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
185 |
3718 | 186 if build == 'product': |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
187 return jdk7 |
3718 | 188 elif build in ['debug', 'fastdebug', 'optimized']: |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
189 res = join(jdk7, build) |
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
190 if not exists(res): |
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
191 if not create: |
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
192 env.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') |
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
193 env.log('[creating ' + res + '...]') |
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
194 os.mkdir(res) |
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
195 for d in ['jre', 'lib', 'bin', 'include']: |
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
196 shutil.copytree(join(jdk7, d), join(res, d)) |
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
197 return res |
3718 | 198 else: |
199 env.abort('Unknown build type: ' + build) | |
200 | |
201 def make(env, args): | |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
202 """builds the GraalVM binary |
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
203 |
3722
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
204 The optional argument specifies what type of VM to build.""" |
3718 | 205 |
206 def fix_jvm_cfg(env, jdk): | |
207 jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg') | |
208 found = False | |
209 if not exists(jvmCfg): | |
210 env.abort(jvmCfg + ' does not exist') | |
211 | |
212 with open(jvmCfg) as f: | |
213 for line in f: | |
214 if '-graal KNOWN' in line: | |
215 found = True | |
216 break | |
217 if not found: | |
218 env.log('Appending "-graal KNOWN" to ' + jvmCfg) | |
219 with open(jvmCfg, 'a') as f: | |
220 f.write('-graal KNOWN\n') | |
221 | |
222 build = 'product' if len(args) == 0 else args[0] | |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
223 jdk7 = _jdk7(env, build, True) |
3718 | 224 if build == 'debug': |
225 build = 'jvmg' | |
226 | |
227 fix_jvm_cfg(env, jdk7) | |
228 | |
229 graalVmDir = join(jdk7, 'jre', 'lib', 'amd64', 'graal') | |
230 if not exists(graalVmDir): | |
231 env.log('Creating Graal directory in JDK7: ' + graalVmDir) | |
232 os.makedirs(graalVmDir) | |
233 | |
234 def filterXusage(line): | |
235 if not 'Xusage.txt' in line: | |
236 sys.stderr.write(line + os.linesep) | |
237 | |
238 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='3', ALT_BOOTDIR=jdk7, INSTALL='y') | |
239 env.run([env.gmake_cmd(), build + 'graal'], cwd=join(graal_home, 'make'), err=filterXusage) | |
240 | |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
241 def vm(env, args, vm='-graal'): |
3722
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
242 """run the GraalVM""" |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
243 |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
244 build = env.vmbuild |
3718 | 245 if env.java_dbg: |
246 args = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'] + args | |
247 os.environ['MAXINE'] = env.check_get_env('GRAAL_HOME') | |
248 exe = join(_jdk7(env, build), 'bin', env.exe_suffix('java')) | |
249 return env.run([exe, vm] + args) | |
250 | |
251 def mx_init(env): | |
3722
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
252 env.vmbuild = 'product' |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
253 env.add_argument('--product', action='store_const', dest='vmbuild', const='product', help='select the product VM') |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
254 env.add_argument('--debug', action='store_const', dest='vmbuild', const='debug', help='select the debug VM') |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
255 env.add_argument('--fastdebug', action='store_const', dest='vmbuild', const='fastdebug', help='select the fast debug VM') |
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
256 env.add_argument('--optimized', action='store_const', dest='vmbuild', const='optimized', help='select the optimized VM') |
3718 | 257 commands = { |
3722
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
258 'dacapo': [dacapo, '[benchmark] [VM options]'], |
3718 | 259 'example': [example, '[-v] example names...'], |
260 'clean': [clean, ''], | |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
261 'make': [make, '[product|debug|fastdebug|optimized]'], |
3718 | 262 'tests': [tests, ''], |
3722
7c5524a4e86e
Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents:
3721
diff
changeset
|
263 'vm': [vm, '[-options] class [args...]'], |
3718 | 264 } |
265 env.commands.update(commands) |