Mercurial > hg > graal-compiler
annotate mx/commands.py @ 4152:527724d26036
Added PyDev configuration for mxtool.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 20 Dec 2011 14:09:53 +0100 |
parents | bf5efc22fb3f |
children | 38c782b84ac2 |
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 | |
4152
527724d26036
Added PyDev configuration for mxtool.
Doug Simon <doug.simon@oracle.com>
parents:
4148
diff
changeset
|
29 import os, sys, shutil, 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""" |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4146
diff
changeset
|
38 mx.clean(args) |
3718 | 39 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
|
40 mx.run([mx.gmake_cmd(), 'clean'], cwd=join(_graal_home, 'make')) |
3718 | 41 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
42 def example(args): |
3718 | 43 """run some or all Graal examples""" |
44 examples = { | |
45 'safeadd': ['com.oracle.max.graal.examples.safeadd', 'com.oracle.max.graal.examples.safeadd.Main'], | |
46 'vectorlib': ['com.oracle.max.graal.examples.vectorlib', 'com.oracle.max.graal.examples.vectorlib.Main'], | |
47 } | |
48 | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
49 def run_example(verbose, project, mainClass): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
50 cp = mx.classpath(project) |
3718 | 51 sharedArgs = ['-Xcomp', '-XX:CompileOnly=Main', mainClass] |
52 | |
53 res = [] | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
54 mx.log("=== Server VM ===") |
3718 | 55 printArg = '-XX:+PrintCompilation' if verbose else '-XX:-PrintCompilation' |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
56 res.append(vm(['-cp', cp, printArg] + sharedArgs, vm="-server")) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
57 mx.log("=== Graal VM ===") |
3718 | 58 printArg = '-G:+PrintCompilation' if verbose else '-G:-PrintCompilation' |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
59 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
|
60 mx.log("=== Graal VM with extensions ===") |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
61 res.append(vm(['-cp', cp, printArg, '-G:+Extend', '-G:-Inline'] + sharedArgs)) |
3718 | 62 |
63 if len([x for x in res if x != 0]) != 0: | |
64 return 1 | |
65 return 0 | |
66 | |
67 verbose = False | |
68 if '-v' in args: | |
69 verbose = True | |
70 args = [a for a in args if a != '-v'] | |
71 | |
72 if len(args) == 0: | |
73 args = examples.keys() | |
74 for a in args: | |
75 config = examples.get(a) | |
76 if config is None: | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
77 mx.log('unknown example: ' + a + ' {available examples = ' + str(examples.keys()) + '}') |
3718 | 78 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
79 mx.log('--------- ' + a + ' ------------') |
3718 | 80 project, mainClass = config |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
81 run_example(verbose, project, mainClass) |
3718 | 82 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
83 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
|
84 """run one or all DaCapo benchmarks""" |
3718 | 85 |
86 benchmarks = { | |
87 'avrora': ['-n', '5'], | |
88 'batik': ['-n', '5'], | |
89 'eclipse': ['-n', '5'], | |
90 'fop': ['-n', '5'], | |
91 'h2': ['-n', '5'], | |
92 'jython': ['-n', '5'], | |
93 'luindex': ['-n', '5'], | |
94 'lusearch': ['-n', '5'], | |
95 'pmd': ['-n', '5'], | |
96 'sunflow': ['-n', '5'], | |
97 'tomcat': ['-n', '5'], | |
98 'tradebeans': ['-n', '5'], | |
99 'tradesoap': ['-n', '5'], | |
100 'xalan': ['-n', '5'], | |
101 } | |
102 | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
103 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
|
104 if not isfile(dacapo) or not dacapo.endswith('.jar'): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
105 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
|
106 |
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 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
|
108 |
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 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
|
110 while len(args) != 0 and not args[0].startswith('-'): |
3718 | 111 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
|
112 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
|
113 config = benchmarks.get(bm) |
3718 | 114 if (config is None): |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
115 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
|
116 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
|
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 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
|
119 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
|
120 |
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 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
|
122 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
|
123 config = benchmarks.get(bm) |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
124 vm(vmOpts + ['Harness'] + config + [bm]) |
3718 | 125 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
126 def _jdk7(build='product', create=False): |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
127 jdk7 = join(_graal_home, 'jdk1.7.0') |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
128 if not exists(jdk7): |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
129 # Assume we are running with a JDK7 |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
130 assert mx.java().version.startswith('1.7') |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
131 srcJdk = mx.java().jdk |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
132 mx.log('Creating ' + jdk7 + ' from ' + srcJdk) |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
133 os.mkdir(jdk7) |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
134 for d in ['bin', 'db', 'include', 'jre', 'lib', 'man']: |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
135 src = join(srcJdk, d) |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
136 dst = join(jdk7, d) |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
137 if not exists(src): |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
138 mx.abort('Host JDK 7 directory is missing: ' + src) |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
139 shutil.copytree(src, dst) |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
140 |
3718 | 141 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
|
142 return jdk7 |
3718 | 143 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
|
144 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
|
145 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
|
146 if not create: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
147 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
148 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
|
149 os.mkdir(res) |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
150 for d in ['bin', 'db', 'include', 'jre', 'lib', 'man']: |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
151 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
|
152 return res |
3718 | 153 else: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
154 mx.abort('Unknown build type: ' + build) |
3718 | 155 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
156 def build(args): |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
157 """builds the GraalVM binary and compiles the Graal classes |
3721
71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents:
3718
diff
changeset
|
158 |
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
|
159 The optional argument specifies what type of VM to build.""" |
3718 | 160 |
4146 | 161 build = 'product' |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4146
diff
changeset
|
162 if len(args) != 0 and not args[0].startswith('-'): |
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4146
diff
changeset
|
163 build = args.pop(0) |
4146 | 164 |
165 # Call mx.build to compile the Java sources | |
4147
55376d8953a6
Improved 'build' and 'clean' commands.
Doug Simon <doug.simon@oracle.com>
parents:
4146
diff
changeset
|
166 mx.build(args + ['--source', '1.7']) |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
167 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
168 def fix_jvm_cfg(jdk): |
3718 | 169 jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg') |
170 found = False | |
171 if not exists(jvmCfg): | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
172 mx.abort(jvmCfg + ' does not exist') |
3718 | 173 |
174 with open(jvmCfg) as f: | |
175 for line in f: | |
176 if '-graal KNOWN' in line: | |
177 found = True | |
178 break | |
179 if not found: | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
180 mx.log('Appending "-graal KNOWN" to ' + jvmCfg) |
3718 | 181 with open(jvmCfg, 'a') as f: |
182 f.write('-graal KNOWN\n') | |
183 | |
4146 | 184 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
185 jdk7 = _jdk7(build, True) |
3718 | 186 if build == 'debug': |
187 build = 'jvmg' | |
188 | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
189 fix_jvm_cfg(jdk7) |
3718 | 190 |
191 graalVmDir = join(jdk7, 'jre', 'lib', 'amd64', 'graal') | |
192 if not exists(graalVmDir): | |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
193 mx.log('Creating Graal directory in JDK7: ' + graalVmDir) |
3718 | 194 os.makedirs(graalVmDir) |
195 | |
196 def filterXusage(line): | |
197 if not 'Xusage.txt' in line: | |
198 sys.stderr.write(line + os.linesep) | |
199 | |
200 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
|
201 mx.run([mx.gmake_cmd(), build + 'graal'], cwd=join(_graal_home, 'make'), err=filterXusage) |
3718 | 202 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
203 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
|
204 """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
|
205 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
206 build = _vmbuild |
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
207 if mx.java().debug: |
3718 | 208 args = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'] + args |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
209 os.environ['GRAAL'] = join(_graal_home, 'graal') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
210 exe = join(_jdk7(build), 'bin', mx.exe_suffix('java')) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
211 return mx.run([exe, vm] + args) |
3718 | 212 |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
213 def ideinit(args): |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
214 """(re)generate Eclipse project configurations |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
215 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
216 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
|
217 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
218 |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
219 def println(out, obj): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
220 out.write(str(obj) + '\n') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
221 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
222 for p in mx.projects(): |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
223 if p.native: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
224 continue |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
225 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
226 if not exists(p.dir): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
227 os.makedirs(p.dir) |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
228 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
229 changedFiles = 0 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
230 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
231 out = StringIO.StringIO() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
232 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
233 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
|
234 println(out, '<classpath>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
235 for src in p.srcDirs: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
236 srcDir = join(p.dir, src) |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
237 if not exists(srcDir): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
238 os.mkdir(srcDir) |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
239 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
|
240 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
241 # 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
|
242 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
|
243 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
244 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
|
245 if dep == p: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
246 continue; |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
247 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
248 if dep.isLibrary(): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
249 if hasattr(dep, 'eclipse.container'): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
250 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
|
251 elif hasattr(dep, 'eclipse.project'): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
252 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
|
253 else: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
254 path = dep.path |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
255 if dep.mustExist: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
256 if isabs(path): |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
257 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
|
258 else: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
259 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
|
260 else: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
261 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
|
262 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
263 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
|
264 println(out, '</classpath>') |
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 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
|
267 changedFiles += 1 |
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 out.close() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
270 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
271 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
|
272 if exists(csConfig): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
273 out = StringIO.StringIO() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
274 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
275 dotCheckstyle = join(p.dir, ".checkstyle") |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
276 checkstyleConfigPath = '/' + p.checkstyleProj + '/.checkstyle_checks.xml' |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
277 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
|
278 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
|
279 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
|
280 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
|
281 println(out, '\t</local-check-config>') |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
282 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
|
283 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
|
284 println(out, '\t</fileset>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
285 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
|
286 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
|
287 println(out, '\t</filter>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
288 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
289 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
|
290 if exists(exclude): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
291 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
|
292 with open(exclude) as f: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
293 for line in f: |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
294 if not line.startswith('#'): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
295 line = line.strip() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
296 exclDir = join(p.dir, line) |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
297 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
|
298 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
|
299 println(out, '\t</filter>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
300 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
301 println(out, '</fileset-config>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
302 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
303 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
|
304 changedFiles += 1 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
305 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
306 out.close() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
307 |
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 = StringIO.StringIO() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
310 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
311 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
|
312 println(out, '<projectDescription>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
313 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
|
314 println(out, '\t<comment></comment>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
315 println(out, '\t<projects>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
316 println(out, '\t</projects>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
317 println(out, '\t<buildSpec>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
318 println(out, '\t\t<buildCommand>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
319 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
|
320 println(out, '\t\t\t<arguments>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
321 println(out, '\t\t\t</arguments>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
322 println(out, '\t\t</buildCommand>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
323 if exists(csConfig): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
324 println(out, '\t\t<buildCommand>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
325 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
|
326 println(out, '\t\t\t<arguments>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
327 println(out, '\t\t\t</arguments>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
328 println(out, '\t\t</buildCommand>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
329 println(out, '\t</buildSpec>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
330 println(out, '\t<natures>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
331 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
|
332 if exists(csConfig): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
333 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
|
334 println(out, '\t</natures>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
335 println(out, '</projectDescription>') |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
336 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
337 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
|
338 changedFiles += 1 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
339 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
340 out.close() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
341 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
342 out = StringIO.StringIO() |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
343 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
344 settingsDir = join(p.dir, ".settings") |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
345 if not exists(settingsDir): |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
346 os.mkdir(settingsDir) |
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 myDir = dirname(__file__) |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
349 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
350 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
|
351 content = f.read() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
352 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
|
353 changedFiles += 1 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
354 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
355 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
|
356 content = f.read() |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
357 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
|
358 changedFiles += 1 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
359 |
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
360 if changedFiles != 0: |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
361 mx.abort(changedFiles) |
3732
3e2e8b8abdaf
Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3730
diff
changeset
|
362 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
363 def mx_init(): |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
364 _vmbuild = 'product' |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
365 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
|
366 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
|
367 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
|
368 mx.add_argument('--optimized', action='store_const', dest='vmbuild', const='optimized', help='select the optimized VM') |
3718 | 369 commands = { |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
370 'build': [build, '[product|debug|fastdebug|optimized]'], |
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
|
371 'dacapo': [dacapo, '[benchmark] [VM options]'], |
3718 | 372 'example': [example, '[-v] example names...'], |
373 'clean': [clean, ''], | |
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
|
374 'vm': [vm, '[-options] class [args...]'], |
4145
9aee7df31417
Removed 'tests' command.
Doug Simon <doug.simon@oracle.com>
parents:
4144
diff
changeset
|
375 'ideinit': [ideinit, ''], |
3718 | 376 } |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
377 mx.commands.update(commands) |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
378 |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
379 def mx_post_parse_cmd_line(opts): |
4148
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
380 version = mx.java().version |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
381 parts = version.split('.') |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
382 assert len(parts) >= 2 |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
383 assert parts[0] == '1' |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
384 major = int(parts[1]) |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
385 if not major >= 7: |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
386 mx.abort('Requires Java version 1.7 or greater, got version ' + version) |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
387 |
bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
Doug Simon <doug.simon@oracle.com>
parents:
4147
diff
changeset
|
388 |
4144
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
389 global _vmbuild |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
390 if not opts.vmbuild is None: |
34527a24bcf8
Adopted mxtool changes.
Doug Simon <doug.simon@oracle.com>
parents:
3736
diff
changeset
|
391 _vmbuild = opts.vmbuild |