Mercurial > hg > graal-jvmci-8
comparison mx/commands.py @ 4582:b24386206122
Made all vm builds go into subdirectories, even product builds to simplify building the various types of VMs (server, client and graal).
Made HotSpot build jobs use the number of CPUs on the host machine.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 13 Feb 2012 23:13:37 +0100 |
parents | bc8b58c11768 |
children | 7e5d8d1c74a1 |
comparison
equal
deleted
inserted
replaced
4581:8f985001dc27 | 4582:b24386206122 |
---|---|
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, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, StringIO | 29 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing |
30 from os.path import join, exists, dirname, basename | 30 from os.path import join, exists, dirname, basename |
31 from argparse import ArgumentParser, REMAINDER | 31 from argparse import ArgumentParser, REMAINDER |
32 import mx | 32 import mx |
33 import sanitycheck | 33 import sanitycheck |
34 import json | 34 import json |
272 | 272 |
273 def _jdk(build='product', create=False): | 273 def _jdk(build='product', create=False): |
274 """ | 274 """ |
275 Get the JDK into which Graal is installed, creating it first if necessary. | 275 Get the JDK into which Graal is installed, creating it first if necessary. |
276 """ | 276 """ |
277 jdk = join(_graal_home, 'jdk' + mx.java().version) | 277 jdk = join(_graal_home, 'jdk' + mx.java().version, build) |
278 jdkContents = ['bin', 'db', 'include', 'jre', 'lib'] | 278 jdkContents = ['bin', 'db', 'include', 'jre', 'lib'] |
279 if mx.get_os() != 'windows': | 279 if mx.get_os() != 'windows': |
280 jdkContents.append('man') | 280 jdkContents.append('man') |
281 if not exists(jdk): | 281 if create: |
282 srcJdk = mx.java().jdk | 282 if not exists(jdk): |
283 mx.log('Creating ' + jdk + ' from ' + srcJdk) | 283 srcJdk = mx.java().jdk |
284 os.mkdir(jdk) | 284 mx.log('Creating ' + jdk + ' from ' + srcJdk) |
285 for d in jdkContents: | 285 os.makedirs(jdk) |
286 src = join(srcJdk, d) | |
287 dst = join(jdk, d) | |
288 if not exists(src): | |
289 mx.abort('Host JDK directory is missing: ' + src) | |
290 shutil.copytree(src, dst) | |
291 | |
292 if build == 'product': | |
293 return jdk | |
294 elif build in ['debug', 'fastdebug']: | |
295 res = join(jdk, build) | |
296 if not exists(res): | |
297 if not create: | |
298 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') | |
299 mx.log('Creating ' + res) | |
300 os.mkdir(res) | |
301 for d in jdkContents: | 286 for d in jdkContents: |
302 shutil.copytree(join(jdk, d), join(res, d)) | 287 src = join(srcJdk, d) |
303 return res | 288 dst = join(jdk, d) |
289 if not exists(src): | |
290 mx.abort('Host JDK directory is missing: ' + src) | |
291 shutil.copytree(src, dst) | |
304 else: | 292 else: |
305 mx.abort('Unknown build type: ' + build) | 293 if not exists(jdk): |
294 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') | |
295 return jdk | |
306 | 296 |
307 # run a command in the windows SDK Debug Shell | 297 # run a command in the windows SDK Debug Shell |
308 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo={}): | 298 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo={}): |
309 newLine = os.linesep | 299 newLine = os.linesep |
310 STARTTOKEN = 'RUNINDEBUGSHELL_STARTSEQUENCE' | 300 STARTTOKEN = 'RUNINDEBUGSHELL_STARTSEQUENCE' |
370 else: | 360 else: |
371 assert vm == 'graal', vm | 361 assert vm == 'graal', vm |
372 buildSuffix = 'graal' | 362 buildSuffix = 'graal' |
373 | 363 |
374 for build in builds: | 364 for build in builds: |
375 jdk = _jdk(build, True) | 365 jdk = _jdk(build, create=True) |
376 | 366 |
377 vmDir = join(jdk, 'jre', 'lib', 'amd64', vm) | 367 vmDir = join(jdk, 'jre', 'lib', 'amd64', vm) |
378 if not exists(vmDir): | 368 if not exists(vmDir): |
379 mx.log('Creating VM directory in JDK7: ' + vmDir) | 369 mx.log('Creating VM directory in JDK7: ' + vmDir) |
380 os.makedirs(vmDir) | 370 os.makedirs(vmDir) |
400 winBuildSuccess = re.compile('Build succeeded.') | 390 winBuildSuccess = re.compile('Build succeeded.') |
401 if not _runInDebugShell(winBuildCmd, _graal_home, compilelogfile, winBuildSuccess): | 391 if not _runInDebugShell(winBuildCmd, _graal_home, compilelogfile, winBuildSuccess): |
402 mx.log('Error building project') | 392 mx.log('Error building project') |
403 return | 393 return |
404 else: | 394 else: |
395 cpus = multiprocessing.cpu_count() | |
405 if build == 'debug': | 396 if build == 'debug': |
406 build = 'jvmg' | 397 build = 'jvmg' |
407 env = os.environ | 398 env = os.environ |
408 env.setdefault('ARCH_DATA_MODEL', '64') | 399 env.setdefault('ARCH_DATA_MODEL', '64') |
409 env.setdefault('LANG', 'C') | 400 env.setdefault('LANG', 'C') |
410 env.setdefault('HOTSPOT_BUILD_JOBS', '3') | 401 env.setdefault('HOTSPOT_BUILD_JOBS', str(cpus)) |
411 env['ALT_BOOTDIR'] = jdk | 402 env['ALT_BOOTDIR'] = jdk |
412 env.setdefault('INSTALL', 'y') | 403 env.setdefault('INSTALL', 'y') |
404 | |
405 # Clear these 2 variables as having them set can cause very confusing build problems | |
406 env.pop('LD_LIBRARY_PATH', None) | |
407 env.pop('CLASSPATH', None) | |
408 | |
413 mx.run([mx.gmake_cmd(), build + buildSuffix], cwd=join(_graal_home, 'make'), err=filterXusage) | 409 mx.run([mx.gmake_cmd(), build + buildSuffix], cwd=join(_graal_home, 'make'), err=filterXusage) |
414 | 410 |
415 jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg') | 411 jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg') |
416 found = False | 412 found = False |
417 if not exists(jvmCfg): | 413 if not exists(jvmCfg): |
449 | 445 |
450 | 446 |
451 # Table of unit tests. | 447 # Table of unit tests. |
452 # Keys are project names, values are package name lists. | 448 # Keys are project names, values are package name lists. |
453 # All source files in the given (project,package) pairs are scanned for lines | 449 # All source files in the given (project,package) pairs are scanned for lines |
454 # containing '@Test'. These are then detemrined to be the classes defining | 450 # containing '@Test'. These are then determined to be the classes defining |
455 # unit tests. | 451 # unit tests. |
456 _unittests = { | 452 _unittests = { |
457 'com.oracle.max.graal.tests': ['com.oracle.max.graal.compiler.tests'], | 453 'com.oracle.max.graal.tests': ['com.oracle.max.graal.compiler.tests'], |
458 } | 454 } |
459 | 455 |
557 tasks.append(t.stop()) | 553 tasks.append(t.stop()) |
558 | 554 |
559 t = Task('CleanAndBuildGraalVisualizer') | 555 t = Task('CleanAndBuildGraalVisualizer') |
560 mx.run(['ant', '-f', join(_graal_home, 'visualizer', 'build.xml'), '-q', 'clean', 'build']) | 556 mx.run(['ant', '-f', join(_graal_home, 'visualizer', 'build.xml'), '-q', 'clean', 'build']) |
561 tasks.append(t.stop()) | 557 tasks.append(t.stop()) |
562 | |
563 tasks.append(t.stop()) | |
564 mx.run(['ant', '-f', join(_graal_home, 'visualizer', 'build.xml'), '-q', 'clean', 'build']) | |
565 tasks.append(t.stop()) | |
566 | 558 |
567 # Prevent Graal modifications from breaking the standard client build | 559 # Prevent Graal modifications from breaking the standard client build |
568 t = Task('BuildClientDebug') | 560 for v in ['client', 'server']: |
569 build(['--no-java', 'debug'], vm='client') | 561 for vmbuild in ['product', 'debug']: |
570 tasks.append(t.stop()) | 562 t = Task('BuildHotSpot' + v.title() + ':' + vmbuild) |
571 | 563 build(['--no-java', vmbuild], vm=v) |
572 # Prevent Graal modifications from breaking the standard server build | 564 tasks.append(t.stop()) |
573 #t = Task('BuildServerDebug') | |
574 #build(['--no-java', 'debug'], vm='server') | |
575 #tasks.append(t.stop()) | |
576 | 565 |
577 for vmbuild in ['fastdebug', 'product']: | 566 for vmbuild in ['fastdebug', 'product']: |
578 global _vmbuild | 567 global _vmbuild |
579 _vmbuild = vmbuild | 568 _vmbuild = vmbuild |
580 | 569 |
581 t = Task('BuildHotSpot:' + vmbuild) | 570 t = Task('BuildHotSpotGraal:' + vmbuild) |
582 build(['--no-java', vmbuild]) | 571 build(['--no-java', vmbuild]) |
583 tasks.append(t.stop()) | 572 tasks.append(t.stop()) |
584 | 573 |
585 t = Task('BootstrapWithSystemAssertions:' + vmbuild) | 574 t = Task('BootstrapWithSystemAssertions:' + vmbuild) |
586 vm(['-esa', '-version']) | 575 vm(['-esa', '-version']) |