annotate mx/commands.py @ 3736:d3ec27ea1b20

Work with GRAAL environment variable instead of MAXINE environment variable.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 17 Dec 2011 20:48:46 +0100
parents 3e2e8b8abdaf
children 34527a24bcf8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 # commands.py - the default commands available to gl.py
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 # ----------------------------------------------------------------------------------------------------
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 # Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 # This code is free software; you can redistribute it and/or modify it
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 # under the terms of the GNU General Public License version 2 only, as
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 # published by the Free Software Foundation.
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 # This code is distributed in the hope that it will be useful, but WITHOUT
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 # version 2 for more details (a copy is included in the LICENSE file that
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 # accompanied this code).
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 # You should have received a copy of the GNU General Public License version
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 # 2 along with this work; if not, write to the Free Software Foundation,
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24 # or visit www.oracle.com if you need additional information or have any
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 # questions.
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26 #
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27 # ----------------------------------------------------------------------------------------------------
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
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
3721
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
30 from os.path import join, exists, dirname, isfile, isdir
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 graal_home = dirname(dirname(__file__))
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 def clean(env, args):
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 """cleans the GraalVM source tree"""
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='16')
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 env.run([env.gmake_cmd(), 'clean'], cwd=join(graal_home, 'make'))
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 def example(env, args):
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 """run some or all Graal examples"""
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 examples = {
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 'safeadd': ['com.oracle.max.graal.examples.safeadd', 'com.oracle.max.graal.examples.safeadd.Main'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43 'vectorlib': ['com.oracle.max.graal.examples.vectorlib', 'com.oracle.max.graal.examples.vectorlib.Main'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44 }
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
45
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 def run_example(env, verbose, project, mainClass):
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 cp = env.pdb.classpath(project)
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 sharedArgs = ['-Xcomp', '-XX:CompileOnly=Main', mainClass]
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 res = []
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51 env.log("=== Server VM ===")
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 printArg = '-XX:+PrintCompilation' if verbose else '-XX:-PrintCompilation'
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
53 res.append(vm(env, ['-cp', cp, printArg] + sharedArgs, vm="-server"))
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
54 env.log("=== Graal VM ===")
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55 printArg = '-G:+PrintCompilation' if verbose else '-G:-PrintCompilation'
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
56 res.append(vm(env, ['-cp', cp, printArg, '-G:-Extend', '-G:-Inline'] + sharedArgs))
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
57 env.log("=== Graal VM with extensions ===")
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
58 res.append(vm(env, ['-cp', cp, printArg, '-G:+Extend', '-G:-Inline'] + sharedArgs))
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60 if len([x for x in res if x != 0]) != 0:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61 return 1
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62 return 0
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
64 verbose = False
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65 if '-v' in args:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
66 verbose = True
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
67 args = [a for a in args if a != '-v']
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
68
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
69 if len(args) == 0:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
70 args = examples.keys()
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71 for a in args:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
72 config = examples.get(a)
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
73 if config is None:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
74 env.log('unknown example: ' + a + ' {available examples = ' + str(examples.keys()) + '}')
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
75 else:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
76 env.log('--------- ' + a + ' ------------')
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
77 project, mainClass = config
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
78 run_example(env, verbose, project, mainClass)
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
79
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
80 def dacapo(env, args):
3722
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
81 """run one or all DaCapo benchmarks"""
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
82
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
83 benchmarks = {
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
84 'avrora': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
85 'batik': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
86 'eclipse': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
87 'fop': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
88 'h2': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
89 'jython': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
90 'luindex': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
91 'lusearch': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
92 'pmd': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
93 'sunflow': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
94 'tomcat': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
95 'tradebeans': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
96 'tradesoap': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
97 'xalan': ['-n', '5'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
98 }
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
99
3722
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
100 dacapo = env.check_get_env('DACAPO_CP')
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
101 if not isfile(dacapo) or not dacapo.endswith('.jar'):
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
102 env.abort('Specified DaCapo jar file does not exist or is not a jar file: ' + dacapo)
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
103
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
104 vmOpts = ['-Xms1g', '-Xmx2g', '-esa', '-cp', dacapo]
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
105
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
106 runs = dict()
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
107 while len(args) != 0 and not args[0].startswith('-'):
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
108 bm = args[0]
3722
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
109 del args[0]
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
110 config = benchmarks.get(bm)
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
111 if (config is None):
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
112 env.abort('unknown benchmark: ' + bm + '\nselect one of: ' + str(benchmarks.keys()))
3722
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
113 runs[bm] = config
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
114
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
115 if len(runs) == 0:
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
116 runs = benchmarks
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
117
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
118 vmOpts += args
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
119 for bm in runs:
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
120 config = benchmarks.get(bm)
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
121 vm(env, vmOpts + ['Harness'] + config + [bm])
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
122
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
123 def tests(env, args):
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
124 """run a selection of the Maxine JTT tests in Graal"""
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
125
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
126 maxine = env.check_get_env('MAXINE_HOME')
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
127 def jtt(name):
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
128 return join(maxine, 'com.oracle.max.vm', 'test', 'jtt', name)
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
129
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
130 return vm(env, ['-ea', '-esa', '-Xcomp', '-XX:+PrintCompilation', '-XX:CompileOnly=jtt'] + args +
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
131 ['-Xbootclasspath/p:' + join(maxine, 'com.oracle.max.vm', 'bin'),
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
132 '-Xbootclasspath/p:' + join(maxine, 'com.oracle.max.base', 'bin'),
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
133 'test.com.sun.max.vm.compiler.JavaTester',
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
134 '-verbose=1', '-gen-run-scheme=false', '-run-scheme-package=all',
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
135 jtt('bytecode'),
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
136 jtt('except'),
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
137 jtt('jdk'),
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
138 jtt('hotpath'),
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
139 jtt('jdk'),
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
140 jtt('lang'),
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
141 jtt('loop'),
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
142 jtt('micro'),
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143 jtt('optimize'),
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
144 jtt('reflect'),
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
145 jtt('threads'),
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
146 jtt('hotspot')])
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
147
3730
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
148
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
149 def _download_and_extract_targz_jdk7(env, url, dst):
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
150 assert url.endswith('.tar.gz')
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
151 dl = join(graal_home, 'jdk7.tar.gz')
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
152 try:
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
153 if not exists(dl):
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
154 env.download(dl, [url])
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
155 tmp = join(graal_home, 'tmp')
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
156 if not exists(tmp):
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
157 os.mkdir(tmp)
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
158 with tarfile.open(dl, mode='r:gz') as f:
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
159 env.log('Extracting ' + dl)
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
160 f.extractall(path=tmp)
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
161 jdk = os.listdir(tmp)[0]
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
162 shutil.move(join(tmp, jdk), dst)
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
163 os.rmdir(tmp)
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
164 os.remove(dl)
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
165 except SystemExit:
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
166 env.abort('Could not download JDK7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html.\n' +
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
167 'Please do this manually and install it at ' + dst + ' or set the JDK7 environment variable to the install location.')
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
168
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
169
3721
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
170 def _jdk7(env, build='product', create=False):
3730
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
171 jdk7 = os.environ.get('JDK7')
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
172 if jdk7 is None:
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
173 jdk7 = join(graal_home, 'jdk7')
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
174 if not exists(jdk7):
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
175 # Try to download it
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
176 if env.os == 'linux':
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
177 _download_and_extract_targz_jdk7(env, 'http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-x64.tar.gz', jdk7)
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
178 else:
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
179 env.abort('Download JDK7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html\n' +
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
180 'and install it at ' + jdk7 + ' or set the JDK7 environment variable to the JDK7 install location.')
4e3851bab8d0 Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
Doug Simon <doug.simon@oracle.com>
parents: 3722
diff changeset
181
3721
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
182 jre = join(jdk7, 'jre')
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
183 if not exists(jre) or not isdir(jre):
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
184 env.abort(jdk7 + ' does not appear to be a valid JDK directory ("jre" sub-directory is missing)')
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
185
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
186 if build == 'product':
3721
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
187 return jdk7
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
188 elif build in ['debug', 'fastdebug', 'optimized']:
3721
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
189 res = join(jdk7, build)
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
190 if not exists(res):
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
191 if not create:
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
192 env.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'')
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
193 env.log('[creating ' + res + '...]')
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
194 os.mkdir(res)
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
195 for d in ['jre', 'lib', 'bin', 'include']:
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
196 shutil.copytree(join(jdk7, d), join(res, d))
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
197 return res
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
198 else:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
199 env.abort('Unknown build type: ' + build)
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
200
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
201 def make(env, args):
3721
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
202 """builds the GraalVM binary
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
203
3722
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
204 The optional argument specifies what type of VM to build."""
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
205
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
206 def fix_jvm_cfg(env, jdk):
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
207 jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg')
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
208 found = False
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
209 if not exists(jvmCfg):
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
210 env.abort(jvmCfg + ' does not exist')
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
211
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
212 with open(jvmCfg) as f:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
213 for line in f:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
214 if '-graal KNOWN' in line:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
215 found = True
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
216 break
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
217 if not found:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
218 env.log('Appending "-graal KNOWN" to ' + jvmCfg)
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
219 with open(jvmCfg, 'a') as f:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
220 f.write('-graal KNOWN\n')
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
221
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
222 build = 'product' if len(args) == 0 else args[0]
3721
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
223 jdk7 = _jdk7(env, build, True)
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
224 if build == 'debug':
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
225 build = 'jvmg'
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
226
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
227 fix_jvm_cfg(env, jdk7)
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
228
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
229 graalVmDir = join(jdk7, 'jre', 'lib', 'amd64', 'graal')
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
230 if not exists(graalVmDir):
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
231 env.log('Creating Graal directory in JDK7: ' + graalVmDir)
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
232 os.makedirs(graalVmDir)
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
233
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
234 def filterXusage(line):
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
235 if not 'Xusage.txt' in line:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
236 sys.stderr.write(line + os.linesep)
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
237
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
238 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='3', ALT_BOOTDIR=jdk7, INSTALL='y')
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
239 env.run([env.gmake_cmd(), build + 'graal'], cwd=join(graal_home, 'make'), err=filterXusage)
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
240
3721
71b1204a74b4 Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
Doug Simon <doug.simon@oracle.com>
parents: 3718
diff changeset
241 def vm(env, args, vm='-graal'):
3722
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
242 """run the GraalVM"""
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
243
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
244 build = env.vmbuild
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
245 if env.java_dbg:
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
246 args = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'] + args
3736
d3ec27ea1b20 Work with GRAAL environment variable instead of MAXINE environment variable.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3732
diff changeset
247 os.environ['GRAAL'] = join(env.check_get_env('GRAAL_HOME'), 'graal')
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
248 exe = join(_jdk7(env, build), 'bin', env.exe_suffix('java'))
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
249 return env.run([exe, vm] + args)
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
250
3732
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
251 def eclipseprojects(env, args):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
252 """(re)generate Eclipse project configurations
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
253
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
254 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
255
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
256 def println(out, obj):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
257 out.write(str(obj) + '\n')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
258
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
259 pdb = env.pdb
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
260 for p in pdb.projects.values():
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
261 if p.native:
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
262 continue
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
263
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
264 d = join(p.baseDir, p.name)
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
265 if not exists(d):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
266 os.makedirs(d)
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
267
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
268 changedFiles = 0
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
269
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
270 out = StringIO.StringIO()
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
271
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
272 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
273 println(out, '<classpath>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
274 for src in p.srcDirs:
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
275 srcDir = join(d, src)
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
276 if not exists(srcDir):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
277 os.mkdir(srcDir)
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
278 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
279
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
280 # 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
281 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
282
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
283 for dep in p.all_deps([], pdb, True):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
284 if dep == p:
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
285 continue;
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
286
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
287 if dep.isLibrary():
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
288 if hasattr(dep, 'eclipse.container'):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
289 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
290 elif hasattr(dep, 'eclipse.project'):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
291 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
292 else:
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
293 path = dep.path
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
294 if dep.mustExist:
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
295 if os.path.isabs(path):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
296 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
297 else:
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
298 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
299 else:
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
300 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
301
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
302 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
303 println(out, '</classpath>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
304
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
305 if env.update_file(join(p.baseDir, p.name, '.classpath'), out.getvalue()):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
306 changedFiles += 1
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 out.close()
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
309
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
310 csConfig = join(p.baseDir, p.checkstyleProj, '.checkstyle_checks.xml')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
311 if exists(csConfig):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
312 out = StringIO.StringIO()
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
313
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
314 dotCheckstyle = join(d, ".checkstyle")
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
315 checkstyleConfigPath = '/' + p.checkstyleProj + '/.checkstyle_checks.xml'
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
316 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
317 println(out, '<fileset-config file-format-version="1.2.0" simple-config="true">')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
318 println(out, '\t<local-check-config name="Maxine Checks" location="' + checkstyleConfigPath + '" type="project" description="">')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
319 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
320 println(out, '\t</local-check-config>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
321 println(out, '\t<fileset name="all" enabled="true" check-config-name="Maxine Checks" local="true">')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
322 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
323 println(out, '\t</fileset>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
324 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
325 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
326 println(out, '\t</filter>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
327
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
328 exclude = join(d, '.checkstyle.exclude')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
329 if exists(exclude):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
330 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
331 with open(exclude) as f:
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
332 for line in f:
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
333 if not line.startswith('#'):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
334 line = line.strip()
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
335 exclDir = join(d, line)
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
336 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
337 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
338 println(out, '\t</filter>')
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 println(out, '</fileset-config>')
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 if env.update_file(dotCheckstyle, out.getvalue()):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
343 changedFiles += 1
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
344
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
345 out.close()
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
346
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 out = StringIO.StringIO()
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 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
351 println(out, '<projectDescription>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
352 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
353 println(out, '\t<comment></comment>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
354 println(out, '\t<projects>')
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<buildSpec>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
357 println(out, '\t\t<buildCommand>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
358 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
359 println(out, '\t\t\t<arguments>')
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</buildCommand>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
362 if exists(csConfig):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
363 println(out, '\t\t<buildCommand>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
364 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
365 println(out, '\t\t\t<arguments>')
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</buildCommand>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
368 println(out, '\t</buildSpec>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
369 println(out, '\t<natures>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
370 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
371 if exists(csConfig):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
372 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
373 println(out, '\t</natures>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
374 println(out, '</projectDescription>')
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
375
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
376 if env.update_file(join(d, '.project'), out.getvalue()):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
377 changedFiles += 1
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
378
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
379 out.close()
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
380
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
381 out = StringIO.StringIO()
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
382
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
383 settingsDir = join(d, ".settings")
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
384 if not exists(settingsDir):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
385 os.mkdir(settingsDir)
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
386
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
387 myDir = dirname(__file__)
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
388
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
389 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
390 content = f.read()
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
391 if env.update_file(join(settingsDir, 'org.eclipse.jdt.core.prefs'), content):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
392 changedFiles += 1
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
393
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
394 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
395 content = f.read()
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
396 if env.update_file(join(settingsDir, 'org.eclipse.jdt.ui.prefs'), content):
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
397 changedFiles += 1
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
398
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
399 if changedFiles != 0:
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
400 env.abort(changedFiles)
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
401
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
402 def mx_init(env):
3722
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
403 env.vmbuild = 'product'
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
404 env.add_argument('--product', action='store_const', dest='vmbuild', const='product', help='select the product VM')
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
405 env.add_argument('--debug', action='store_const', dest='vmbuild', const='debug', help='select the debug VM')
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
406 env.add_argument('--fastdebug', action='store_const', dest='vmbuild', const='fastdebug', help='select the fast debug VM')
7c5524a4e86e Unified the way a specific build of the VM is chosen for any mx command that runs the GraalVM.
Doug Simon <doug.simon@oracle.com>
parents: 3721
diff changeset
407 env.add_argument('--optimized', action='store_const', dest='vmbuild', const='optimized', help='select the optimized VM')
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
408 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
409 'dacapo': [dacapo, '[benchmark] [VM options]'],
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
410 'example': [example, '[-v] example names...'],
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
411 '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
412 'make': [make, '[product|debug|fastdebug|optimized]'],
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
413 '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
414 'vm': [vm, '[-options] class [args...]'],
3732
3e2e8b8abdaf Updated mxtool to allow projects in subdirectories.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3730
diff changeset
415 'eclipseprojects': [eclipseprojects, ''],
3718
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
416 }
42e655a6a6f3 Added mx configuration.
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
417 env.commands.update(commands)