Mercurial > hg > graal-jvmci-8
comparison mx/commands.py @ 3721:71b1204a74b4
Automated creation of debug, fastdebug and optimized subdirectories of the JDK.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 16 Dec 2011 15:17:17 +0100 |
parents | 42e655a6a6f3 |
children | 7c5524a4e86e |
comparison
equal
deleted
inserted
replaced
3720:bb1924f0625b | 3721:71b1204a74b4 |
---|---|
24 # or visit www.oracle.com if you need additional information or have any | 24 # or visit www.oracle.com if you need additional information or have any |
25 # questions. | 25 # questions. |
26 # | 26 # |
27 # ---------------------------------------------------------------------------------------------------- | 27 # ---------------------------------------------------------------------------------------------------- |
28 | 28 |
29 import os, sys | 29 import os, sys, shutil |
30 from os.path import join, exists, dirname, isfile | 30 from os.path import join, exists, dirname, isfile, isdir |
31 | 31 |
32 graal_home = dirname(dirname(__file__)) | 32 graal_home = dirname(dirname(__file__)) |
33 | 33 |
34 def clean(env, args): | 34 def clean(env, args): |
35 """cleans the GraalVM source tree""" | 35 """cleans the GraalVM source tree""" |
133 jtt('optimize'), | 133 jtt('optimize'), |
134 jtt('reflect'), | 134 jtt('reflect'), |
135 jtt('threads'), | 135 jtt('threads'), |
136 jtt('hotspot')]) | 136 jtt('hotspot')]) |
137 | 137 |
138 def _jdk7(env, build='product'): | 138 def _jdk7(env, build='product', create=False): |
139 jdk7 = env.check_get_env('JDK7') | 139 jdk7 = env.check_get_env('JDK7') |
140 jre = join(jdk7, 'jre') | |
141 if not exists(jre) or not isdir(jre): | |
142 env.abort(jdk7 + ' does not appear to be a valid JDK directory ("jre" sub-directory is missing)') | |
143 | |
140 if build == 'product': | 144 if build == 'product': |
141 pass | 145 return jdk7 |
142 elif build in ['debug', 'fastdebug', 'optimized']: | 146 elif build in ['debug', 'fastdebug', 'optimized']: |
143 jdk7 = join(jdk7, build) | 147 res = join(jdk7, build) |
148 if not exists(res): | |
149 if not create: | |
150 env.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') | |
151 env.log('[creating ' + res + '...]') | |
152 os.mkdir(res) | |
153 for d in ['jre', 'lib', 'bin', 'include']: | |
154 shutil.copytree(join(jdk7, d), join(res, d)) | |
155 return res | |
144 else: | 156 else: |
145 env.abort('Unknown build type: ' + build) | 157 env.abort('Unknown build type: ' + build) |
146 return jdk7 | |
147 | 158 |
148 def make(env, args): | 159 def make(env, args): |
149 """builds the GraalVM binary""" | 160 """builds the GraalVM binary |
161 | |
162 The optional argument specifies what type of VM to build. | |
163 """ | |
150 | 164 |
151 def fix_jvm_cfg(env, jdk): | 165 def fix_jvm_cfg(env, jdk): |
152 jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg') | 166 jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg') |
153 found = False | 167 found = False |
154 if not exists(jvmCfg): | 168 if not exists(jvmCfg): |
163 env.log('Appending "-graal KNOWN" to ' + jvmCfg) | 177 env.log('Appending "-graal KNOWN" to ' + jvmCfg) |
164 with open(jvmCfg, 'a') as f: | 178 with open(jvmCfg, 'a') as f: |
165 f.write('-graal KNOWN\n') | 179 f.write('-graal KNOWN\n') |
166 | 180 |
167 build = 'product' if len(args) == 0 else args[0] | 181 build = 'product' if len(args) == 0 else args[0] |
168 jdk7 = _jdk7(env, build) | 182 jdk7 = _jdk7(env, build, True) |
169 if build == 'debug': | 183 if build == 'debug': |
170 build = 'jvmg' | 184 build = 'jvmg' |
171 | 185 |
172 fix_jvm_cfg(env, jdk7) | 186 fix_jvm_cfg(env, jdk7) |
173 | |
174 if env.os != 'windows': | |
175 javaLink = join(graal_home, 'hotspot', 'java') | |
176 if not exists(javaLink): | |
177 javaExe = join(jdk7, 'jre', 'bin', 'java') | |
178 env.log('Creating link: ' + javaLink + ' -> ' + javaExe) | |
179 os.symlink(javaExe, javaLink) | |
180 | 187 |
181 graalVmDir = join(jdk7, 'jre', 'lib', 'amd64', 'graal') | 188 graalVmDir = join(jdk7, 'jre', 'lib', 'amd64', 'graal') |
182 if not exists(graalVmDir): | 189 if not exists(graalVmDir): |
183 env.log('Creating Graal directory in JDK7: ' + graalVmDir) | 190 env.log('Creating Graal directory in JDK7: ' + graalVmDir) |
184 os.makedirs(graalVmDir) | 191 os.makedirs(graalVmDir) |
188 sys.stderr.write(line + os.linesep) | 195 sys.stderr.write(line + os.linesep) |
189 | 196 |
190 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='3', ALT_BOOTDIR=jdk7, INSTALL='y') | 197 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='3', ALT_BOOTDIR=jdk7, INSTALL='y') |
191 env.run([env.gmake_cmd(), build + 'graal'], cwd=join(graal_home, 'make'), err=filterXusage) | 198 env.run([env.gmake_cmd(), build + 'graal'], cwd=join(graal_home, 'make'), err=filterXusage) |
192 | 199 |
193 def vm(env, args, vm='-graal', build='product'): | 200 def vm(env, args, vm='-graal'): |
194 """run the GraalVM""" | 201 """run the GraalVM |
202 | |
203 The optional leading argument specifies an alternative to the | |
204 product build should be run: @g = debug, @f = fastdebug, @o = optimized""" | |
205 | |
206 build = 'product' | |
207 buildOpts = { | |
208 '@g': 'debug', | |
209 '@f': 'fastdebug', | |
210 '@o': 'optimized' | |
211 } | |
212 | |
213 if len(args) and args[0] in buildOpts.iterkeys(): | |
214 build = buildOpts[args[0]] | |
215 del args[0] | |
216 | |
195 if env.java_dbg: | 217 if env.java_dbg: |
196 args = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'] + args | 218 args = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'] + args |
197 os.environ['MAXINE'] = env.check_get_env('GRAAL_HOME') | 219 os.environ['MAXINE'] = env.check_get_env('GRAAL_HOME') |
198 exe = join(_jdk7(env, build), 'bin', env.exe_suffix('java')) | 220 exe = join(_jdk7(env, build), 'bin', env.exe_suffix('java')) |
199 return env.run([exe, vm] + args) | 221 return env.run([exe, vm] + args) |
200 | 222 |
201 def vm_g(env, args): | |
202 """run the debug GraalVM""" | |
203 return vm(env, args, build='debug') | |
204 | |
205 def vm_f(env, args): | |
206 """run the fastdebug GraalVM""" | |
207 return vm(env, args, build='fastdebug') | |
208 | |
209 def vm_o(env, args): | |
210 """run the optimized GraalVM""" | |
211 return vm(env, args, build='optimized') | |
212 | |
213 def mx_init(env): | 223 def mx_init(env): |
214 commands = { | 224 commands = { |
215 'dacapo': [dacapo, 'benchmark [VM options]'], | 225 'dacapo': [dacapo, 'benchmark [VM options]'], |
216 'example': [example, '[-v] example names...'], | 226 'example': [example, '[-v] example names...'], |
217 'clean': [clean, ''], | 227 'clean': [clean, ''], |
218 'make': [make, ''], | 228 'make': [make, '[product|debug|fastdebug|optimized]'], |
219 'tests': [tests, ''], | 229 'tests': [tests, ''], |
220 'vm_g': [vm_g, ''], | 230 'vm': [vm, '[@g|@f|@o] [-options] class [args...]'], |
221 'vm_f': [vm_f, ''], | |
222 'vm_o': [vm_o, ''], | |
223 'vm': [vm, ''], | |
224 } | 231 } |
225 env.commands.update(commands) | 232 env.commands.update(commands) |
226 | 233 |
227 def run_dacapo(env, args): | 234 def run_dacapo(env, args): |
228 dacapo = env.check_get_env('DACAPO_CP') | 235 dacapo = env.check_get_env('DACAPO_CP') |