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