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