Mercurial > hg > truffle
annotate mx/commands.py @ 4144:34527a24bcf8
Adopted mxtool changes.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 19 Dec 2011 18:31:09 +0100 |
parents | d3ec27ea1b20 |
children | 9aee7df31417 |
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 | |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
29 import os, sys, shutil, tarfile, StringIO |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
30 from os.path import join, exists, dirname, isfile, isdir, isabs |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
31 import mx |
3718 | 32 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
33 _graal_home = dirname(dirname(__file__)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
34 _vmbuild = 'product' |
3718 | 35 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
36 def clean(args): |
3718 | 37 """cleans the GraalVM source tree""" |
38 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='16') | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
39 mx.run([mx.gmake_cmd(), 'clean'], cwd=join(_graal_home, 'make')) |
3718 | 40 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
41 def example(args): |
3718 | 42 """run some or all Graal examples""" |
43 examples = { | |
44 'safeadd': ['com.oracle.max.graal.examples.safeadd', 'com.oracle.max.graal.examples.safeadd.Main'], | |
45 'vectorlib': ['com.oracle.max.graal.examples.vectorlib', 'com.oracle.max.graal.examples.vectorlib.Main'], | |
46 } | |
47 | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
48 def run_example(verbose, project, mainClass): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
49 cp = mx.classpath(project) |
3718 | 50 sharedArgs = ['-Xcomp', '-XX:CompileOnly=Main', mainClass] |
51 | |
52 res = [] | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
53 mx.log("=== Server VM ===") |
3718 | 54 printArg = '-XX:+PrintCompilation' if verbose else '-XX:-PrintCompilation' |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
55 res.append(vm(['-cp', cp, printArg] + sharedArgs, vm="-server")) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
56 mx.log("=== Graal VM ===") |
3718 | 57 printArg = '-G:+PrintCompilation' if verbose else '-G:-PrintCompilation' |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
58 res.append(vm(['-cp', cp, printArg, '-G:-Extend', '-G:-Inline'] + sharedArgs)) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
59 mx.log("=== Graal VM with extensions ===") |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
60 res.append(vm(['-cp', cp, printArg, '-G:+Extend', '-G:-Inline'] + sharedArgs)) |
3718 | 61 |
62 if len([x for x in res if x != 0]) != 0: | |
63 return 1 | |
64 return 0 | |
65 | |
66 verbose = False | |
67 if '-v' in args: | |
68 verbose = True | |
69 args = [a for a in args if a != '-v'] | |
70 | |
71 if len(args) == 0: | |
72 args = examples.keys() | |
73 for a in args: | |
74 config = examples.get(a) | |
75 if config is None: | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
76 mx.log('unknown example: ' + a + ' {available examples = ' + str(examples.keys()) + '}') |
3718 | 77 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
78 mx.log('--------- ' + a + ' ------------') |
3718 | 79 project, mainClass = config |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
80 run_example(verbose, project, mainClass) |
3718 | 81 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
82 def dacapo(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
|
83 """run one or all DaCapo benchmarks""" |
3718 | 84 |
85 benchmarks = { | |
86 'avrora': ['-n', '5'], | |
87 'batik': ['-n', '5'], | |
88 'eclipse': ['-n', '5'], | |
89 'fop': ['-n', '5'], | |
90 'h2': ['-n', '5'], | |
91 'jython': ['-n', '5'], | |
92 'luindex': ['-n', '5'], | |
93 'lusearch': ['-n', '5'], | |
94 'pmd': ['-n', '5'], | |
95 'sunflow': ['-n', '5'], | |
96 'tomcat': ['-n', '5'], | |
97 'tradebeans': ['-n', '5'], | |
98 'tradesoap': ['-n', '5'], | |
99 'xalan': ['-n', '5'], | |
100 } | |
101 | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
102 dacapo = mx.check_get_env('DACAPO_CP') |
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
|
103 if not isfile(dacapo) or not dacapo.endswith('.jar'): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
104 mx.abort('Specified DaCapo jar file does not exist or is not a jar file: ' + dacapo) |
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
|
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 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
|
107 |
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
|
108 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
|
109 while len(args) != 0 and not args[0].startswith('-'): |
3718 | 110 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
|
111 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
|
112 config = benchmarks.get(bm) |
3718 | 113 if (config is None): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
114 mx.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
|
115 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
|
116 |
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 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
|
118 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
|
119 |
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 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
|
121 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
|
122 config = benchmarks.get(bm) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
123 vm(vmOpts + ['Harness'] + config + [bm]) |
3718 | 124 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
125 def tests(args): |
3718 | 126 """run a selection of the Maxine JTT tests in Graal""" |
127 | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
128 maxine = mx.check_get_env('MAXINE_HOME') |
3718 | 129 def jtt(name): |
130 return join(maxine, 'com.oracle.max.vm', 'test', 'jtt', name) | |
131 | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
132 return vm(['-ea', '-esa', '-Xcomp', '-XX:+PrintCompilation', '-XX:CompileOnly=jtt'] + args + |
3718 | 133 ['-Xbootclasspath/p:' + join(maxine, 'com.oracle.max.vm', 'bin'), |
134 '-Xbootclasspath/p:' + join(maxine, 'com.oracle.max.base', 'bin'), | |
135 'test.com.sun.max.vm.compiler.JavaTester', | |
136 '-verbose=1', '-gen-run-scheme=false', '-run-scheme-package=all', | |
137 jtt('bytecode'), | |
138 jtt('except'), | |
139 jtt('jdk'), | |
140 jtt('hotpath'), | |
141 jtt('jdk'), | |
142 jtt('lang'), | |
143 jtt('loop'), | |
144 jtt('micro'), | |
145 jtt('optimize'), | |
146 jtt('reflect'), | |
147 jtt('threads'), | |
148 jtt('hotspot')]) | |
149 | |
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
|
150 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
151 def _download_and_extract_targz_jdk7(url, dst): |
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
|
152 assert url.endswith('.tar.gz') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
153 dl = join(_graal_home, 'jdk7.tar.gz') |
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
|
154 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
|
155 if not exists(dl): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
156 mx.download(dl, [url]) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
157 tmp = join(_graal_home, 'tmp') |
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
|
158 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
|
159 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
|
160 with tarfile.open(dl, mode='r:gz') as f: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
161 mx.log('Extracting ' + dl) |
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
|
162 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
|
163 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
|
164 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
|
165 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
|
166 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
|
167 except SystemExit: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
168 mx.abort('Could not download JDK7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html.\n' + |
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
|
169 '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
|
170 |
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 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
172 def _jdk7(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
|
173 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
|
174 if jdk7 is None: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
175 jdk7 = join(_graal_home, 'jdk7') |
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
|
176 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
|
177 # Try to download it |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
178 if mx.get_os() == 'linux': |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
179 _download_and_extract_targz_jdk7('http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-x64.tar.gz', jdk7) |
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
|
180 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
181 mx.abort('Download JDK7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html\n' + |
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
|
182 '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
|
183 |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
184 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
|
185 if not exists(jre) or not isdir(jre): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
186 mx.abort(jdk7 + ' does not appear to be a valid JDK directory ("jre" sub-directory is missing)') |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
187 |
3718 | 188 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
|
189 return jdk7 |
3718 | 190 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
|
191 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
|
192 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
|
193 if not create: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
194 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
195 mx.log('[creating ' + res + '...]') |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 return res |
3718 | 200 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
201 mx.abort('Unknown build type: ' + build) |
3718 | 202 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
203 def make(args): |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
204 """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
|
205 |
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
|
206 The optional argument specifies what type of VM to build.""" |
3718 | 207 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
208 def fix_jvm_cfg(jdk): |
3718 | 209 jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg') |
210 found = False | |
211 if not exists(jvmCfg): | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
212 mx.abort(jvmCfg + ' does not exist') |
3718 | 213 |
214 with open(jvmCfg) as f: | |
215 for line in f: | |
216 if '-graal KNOWN' in line: | |
217 found = True | |
218 break | |
219 if not found: | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
220 mx.log('Appending "-graal KNOWN" to ' + jvmCfg) |
3718 | 221 with open(jvmCfg, 'a') as f: |
222 f.write('-graal KNOWN\n') | |
223 | |
224 build = 'product' if len(args) == 0 else args[0] | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
225 jdk7 = _jdk7(build, True) |
3718 | 226 if build == 'debug': |
227 build = 'jvmg' | |
228 | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
229 fix_jvm_cfg(jdk7) |
3718 | 230 |
231 graalVmDir = join(jdk7, 'jre', 'lib', 'amd64', 'graal') | |
232 if not exists(graalVmDir): | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
233 mx.log('Creating Graal directory in JDK7: ' + graalVmDir) |
3718 | 234 os.makedirs(graalVmDir) |
235 | |
236 def filterXusage(line): | |
237 if not 'Xusage.txt' in line: | |
238 sys.stderr.write(line + os.linesep) | |
239 | |
240 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='3', ALT_BOOTDIR=jdk7, INSTALL='y') | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
241 mx.run([mx.gmake_cmd(), build + 'graal'], cwd=join(_graal_home, 'make'), err=filterXusage) |
3718 | 242 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
243 def vm(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
|
244 """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
|
245 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
246 build = mx.vmbuild |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
247 if mx.java_dbg: |
3718 | 248 args = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'] + args |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
249 os.environ['GRAAL'] = join(mx.check_get_env('GRAAL_HOME'), 'graal') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
250 exe = join(_jdk7(build), 'bin', mx.exe_suffix('java')) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
251 return mx.run([exe, vm] + args) |
3718 | 252 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
253 def eclipseprojects(args): |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
254 """(re)generate Eclipse project configurations |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
255 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
256 The exit code of this command reflects how many files were updated.""" |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
257 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
258 |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
259 def println(out, obj): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
260 out.write(str(obj) + '\n') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
261 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
262 for p in mx.projects(): |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
263 if p.native: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
264 continue |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
265 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
266 if not exists(p.dir): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
267 os.makedirs(p.dir) |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
268 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
269 changedFiles = 0 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
270 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
271 out = StringIO.StringIO() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
272 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
273 println(out, '<?xml version="1.0" encoding="UTF-8"?>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
274 println(out, '<classpath>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
275 for src in p.srcDirs: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
276 srcDir = join(p.dir, src) |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
277 if not exists(srcDir): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
278 os.mkdir(srcDir) |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
279 println(out, '\t<classpathentry kind="src" path="' + src + '"/>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
280 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
281 # Every Java program depends on the JRE |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
282 println(out, '\t<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
283 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
284 for dep in p.all_deps([], True): |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
285 if dep == p: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
286 continue; |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
287 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
288 if dep.isLibrary(): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
289 if hasattr(dep, 'eclipse.container'): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
290 println(out, '\t<classpathentry exported="true" kind="con" path="' + getattr(dep, 'eclipse.container') + '"/>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
291 elif hasattr(dep, 'eclipse.project'): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
292 println(out, '\t<classpathentry combineaccessrules="false" exported="true" kind="src" path="/' + getattr(dep, 'eclipse.project') + '"/>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
293 else: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
294 path = dep.path |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
295 if dep.mustExist: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
296 if isabs(path): |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
297 println(out, '\t<classpathentry exported="true" kind="lib" path="' + path + '"/>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
298 else: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
299 println(out, '\t<classpathentry exported="true" kind="lib" path="/' + path + '"/>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
300 else: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
301 println(out, '\t<classpathentry combineaccessrules="false" exported="true" kind="src" path="/' + dep.name + '"/>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
302 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
303 println(out, '\t<classpathentry kind="output" path="' + getattr(p, 'eclipse.output', 'bin') + '"/>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
304 println(out, '</classpath>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
305 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
306 if mx.update_file(join(p.dir, '.classpath'), out.getvalue()): |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
307 changedFiles += 1 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
308 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
309 out.close() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
310 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
311 csConfig = join(mx.project(p.checkstyleProj).dir, '.checkstyle_checks.xml') |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
312 if exists(csConfig): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
313 out = StringIO.StringIO() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
314 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
315 dotCheckstyle = join(p.dir, ".checkstyle") |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
316 checkstyleConfigPath = '/' + p.checkstyleProj + '/.checkstyle_checks.xml' |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
317 println(out, '<?xml version="1.0" encoding="UTF-8"?>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
318 println(out, '<fileset-config file-format-version="1.2.0" simple-config="true">') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
319 println(out, '\t<local-check-config name="Graal Checks" location="' + checkstyleConfigPath + '" type="project" description="">') |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
320 println(out, '\t\t<additional-data name="protect-config-file" value="false"/>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
321 println(out, '\t</local-check-config>') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
322 println(out, '\t<fileset name="all" enabled="true" check-config-name="Graal Checks" local="true">') |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
323 println(out, '\t\t<file-match-pattern match-pattern="." include-pattern="true"/>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
324 println(out, '\t</fileset>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
325 println(out, '\t<filter name="FileTypesFilter" enabled="true">') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
326 println(out, '\t\t<filter-data value="java"/>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
327 println(out, '\t</filter>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
328 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
329 exclude = join(p.dir, '.checkstyle.exclude') |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
330 if exists(exclude): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
331 println(out, '\t<filter name="FilesFromPackage" enabled="true">') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
332 with open(exclude) as f: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
333 for line in f: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
334 if not line.startswith('#'): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
335 line = line.strip() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
336 exclDir = join(p.dir, line) |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
337 assert isdir(exclDir), 'excluded source directory listed in ' + exclude + ' does not exist or is not a directory: ' + exclDir |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
338 println(out, '\t\t<filter-data value="' + line + '"/>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
339 println(out, '\t</filter>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
340 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
341 println(out, '</fileset-config>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
342 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
343 if mx.update_file(dotCheckstyle, out.getvalue()): |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
344 changedFiles += 1 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
345 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
346 out.close() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
347 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
348 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
349 out = StringIO.StringIO() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
350 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
351 println(out, '<?xml version="1.0" encoding="UTF-8"?>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
352 println(out, '<projectDescription>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
353 println(out, '\t<name>' + p.name + '</name>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
354 println(out, '\t<comment></comment>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
355 println(out, '\t<projects>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
356 println(out, '\t</projects>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
357 println(out, '\t<buildSpec>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
358 println(out, '\t\t<buildCommand>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
359 println(out, '\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
360 println(out, '\t\t\t<arguments>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
361 println(out, '\t\t\t</arguments>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
362 println(out, '\t\t</buildCommand>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
363 if exists(csConfig): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
364 println(out, '\t\t<buildCommand>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
365 println(out, '\t\t\t<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
366 println(out, '\t\t\t<arguments>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
367 println(out, '\t\t\t</arguments>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
368 println(out, '\t\t</buildCommand>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
369 println(out, '\t</buildSpec>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
370 println(out, '\t<natures>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
371 println(out, '\t\t<nature>org.eclipse.jdt.core.javanature</nature>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
372 if exists(csConfig): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
373 println(out, '\t\t<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
374 println(out, '\t</natures>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
375 println(out, '</projectDescription>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
376 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
377 if mx.update_file(join(p.dir, '.project'), out.getvalue()): |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
378 changedFiles += 1 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
379 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
380 out.close() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
381 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
382 out = StringIO.StringIO() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
383 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
384 settingsDir = join(p.dir, ".settings") |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
385 if not exists(settingsDir): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
386 os.mkdir(settingsDir) |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
387 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
388 myDir = dirname(__file__) |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
389 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
390 with open(join(myDir, 'org.eclipse.jdt.core.prefs')) as f: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
391 content = f.read() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
392 if mx.update_file(join(settingsDir, 'org.eclipse.jdt.core.prefs'), content): |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
393 changedFiles += 1 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
394 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
395 with open(join(myDir, 'org.eclipse.jdt.ui.prefs')) as f: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
396 content = f.read() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
397 if mx.update_file(join(settingsDir, 'org.eclipse.jdt.ui.prefs'), content): |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
398 changedFiles += 1 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
399 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
400 if changedFiles != 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
401 mx.abort(changedFiles) |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
402 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
403 def mx_init(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
404 _vmbuild = 'product' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
405 mx.add_argument('--product', action='store_const', dest='vmbuild', const='product', help='select the product VM') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
406 mx.add_argument('--debug', action='store_const', dest='vmbuild', const='debug', help='select the debug VM') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
407 mx.add_argument('--fastdebug', action='store_const', dest='vmbuild', const='fastdebug', help='select the fast debug VM') |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
408 mx.add_argument('--optimized', action='store_const', dest='vmbuild', const='optimized', help='select the optimized VM') |
3718 | 409 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
|
410 'dacapo': [dacapo, '[benchmark] [VM options]'], |
3718 | 411 'example': [example, '[-v] example names...'], |
412 '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
|
413 'make': [make, '[product|debug|fastdebug|optimized]'], |
3718 | 414 '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
|
415 'vm': [vm, '[-options] class [args...]'], |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
416 'eclipseprojects': [eclipseprojects, ''], |
3718 | 417 } |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
418 mx.commands.update(commands) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
419 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
420 def mx_post_parse_cmd_line(opts): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
421 global _vmbuild |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
422 if not opts.vmbuild is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
423 _vmbuild = opts.vmbuild |