comparison mx/commands.py @ 4584:7e5d8d1c74a1

Modified JDK replication process such that a copy of the default VM is made. This prevents issues with the replicated JDK being used to bootstrap a HotSpot build. Added 'mx buildvms' command for building various VMs and configurations.
author Doug Simon <doug.simon@oracle.com>
date Tue, 14 Feb 2012 12:29:11 +0100
parents b24386206122
children 5b04b33dac74 ade18666f2be
comparison
equal deleted inserted replaced
4583:597bc897257d 4584:7e5d8d1c74a1
267 if not sanitycheck.getScalaDacapo(test, n, dacapoArgs).test('graal', opts=vmOpts): 267 if not sanitycheck.getScalaDacapo(test, n, dacapoArgs).test('graal', opts=vmOpts):
268 failed.append(test) 268 failed.append(test)
269 269
270 if len(failed) != 0: 270 if len(failed) != 0:
271 mx.abort('Scala DaCapo failures: ' + str(failed)) 271 mx.abort('Scala DaCapo failures: ' + str(failed))
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, build) 277 jdk = join(_graal_home, 'jdk' + mx.java().version, build)
287 src = join(srcJdk, d) 287 src = join(srcJdk, d)
288 dst = join(jdk, d) 288 dst = join(jdk, d)
289 if not exists(src): 289 if not exists(src):
290 mx.abort('Host JDK directory is missing: ' + src) 290 mx.abort('Host JDK directory is missing: ' + src)
291 shutil.copytree(src, dst) 291 shutil.copytree(src, dst)
292
293 # Make a copy of the default VM so that this JDK can be
294 # reliably used as the bootstrap for a HotSpot build.
295 jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg')
296 if not exists(jvmCfg):
297 mx.abort(jvmCfg + ' does not exist')
298
299 lines = []
300 defaultVM = None
301 with open(jvmCfg) as f:
302 for line in f:
303 if line.startswith('-') and defaultVM is None:
304 parts = line.split()
305 assert len(parts) == 2, parts
306 assert parts[1] == 'KNOWN', parts[1]
307 defaultVM = parts[0][1:]
308 lines.append('-' + defaultVM + '0 KNOWN\n')
309 lines.append(line)
310
311 assert defaultVM is not None, 'Could not find default VM in ' + jvmCfg
312 shutil.copytree(join(jdk, 'jre', 'lib', 'amd64', defaultVM), join(jdk, 'jre', 'lib', 'amd64', defaultVM + '0'))
313
314 with open(jvmCfg, 'w') as f:
315 for line in lines:
316 f.write(line)
317
292 else: 318 else:
293 if not exists(jdk): 319 if not exists(jdk):
294 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') 320 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'')
295 return jdk 321 return jdk
296 322
502 classes = [c for c in classes if not containsAny(c, neg)] 528 classes = [c for c in classes if not containsAny(c, neg)]
503 529
504 # (ds) The boot class path must be used for some reason I don't quite understand 530 # (ds) The boot class path must be used for some reason I don't quite understand
505 vm(['-XX:-BootstrapGraal', '-esa', '-Xbootclasspath/a:' + mx.classpath(proj), 'org.junit.runner.JUnitCore'] + classes) 531 vm(['-XX:-BootstrapGraal', '-esa', '-Xbootclasspath/a:' + mx.classpath(proj), 'org.junit.runner.JUnitCore'] + classes)
506 532
533 def buildvms(args):
534 """build one or more VMs in various configurations"""
535
536 parser = ArgumentParser(prog='mx buildvms');
537 parser.add_argument('--vms', help='a comma separated list of VMs to build (default: server,client,graal)', default='server,client,graal')
538 parser.add_argument('--builds', help='a comma separated list of build types (default: product,fastdebug,debug)', default='product,fastdebug,debug')
539
540 args = parser.parse_args(args)
541 vms = args.vms.split(',')
542 builds = args.builds.split(',')
543
544 allStart = time.time()
545 for v in vms:
546 for vmbuild in builds:
547 logFile = join(v + '-' + vmbuild + '.log')
548 log = open(join(_graal_home, logFile), 'wb')
549 start = time.time()
550 mx.log('BEGIN: ' + v + '-' + vmbuild + '\t(see: ' + logFile + ')')
551 # Run as subprocess so that output can be directed to a file
552 subprocess.check_call([sys.executable, '-u', join('mxtool', 'mx.py'), '--vm', v, 'build', vmbuild], cwd=_graal_home, stdout=log, stderr=subprocess.STDOUT)
553 duration = datetime.timedelta(seconds=time.time() - start)
554 mx.log('END: ' + v + '-' + vmbuild + '\t[' + str(duration) + ']')
555 allDuration = datetime.timedelta(seconds=time.time() - allStart)
556 mx.log('TOTAL TIME: ' + '[' + str(allDuration) + ']')
557
507 def gate(args): 558 def gate(args):
508 """run the tests used to validate a push 559 """run the tests used to validate a push
509 560
510 If this command exits with a 0 exit code, then the source code is in 561 If this command exits with a 0 exit code, then the source code is in
511 a state that would be accepted for integration into the main repository.""" 562 a state that would be accepted for integration into the main repository."""
554 605
555 t = Task('CleanAndBuildGraalVisualizer') 606 t = Task('CleanAndBuildGraalVisualizer')
556 mx.run(['ant', '-f', join(_graal_home, 'visualizer', 'build.xml'), '-q', 'clean', 'build']) 607 mx.run(['ant', '-f', join(_graal_home, 'visualizer', 'build.xml'), '-q', 'clean', 'build'])
557 tasks.append(t.stop()) 608 tasks.append(t.stop())
558 609
559 # Prevent Graal modifications from breaking the standard client build 610 # Prevent Graal modifications from breaking the standard builds
560 for v in ['client', 'server']: 611 t = Task('BuildHotSpotVarieties')
561 for vmbuild in ['product', 'debug']: 612 buildvms(['--vms', 'client,server', '--builds', 'fastdebug,product'])
562 t = Task('BuildHotSpot' + v.title() + ':' + vmbuild) 613 tasks.append(t.stop())
563 build(['--no-java', vmbuild], vm=v) 614
564 tasks.append(t.stop())
565
566 for vmbuild in ['fastdebug', 'product']: 615 for vmbuild in ['fastdebug', 'product']:
567 global _vmbuild 616 global _vmbuild
568 _vmbuild = vmbuild 617 _vmbuild = vmbuild
569 618
570 t = Task('BuildHotSpotGraal:' + vmbuild) 619 t = Task('BuildHotSpotGraal:' + vmbuild)
571 build(['--no-java', vmbuild]) 620 buildvms(['--vms', 'graal', '--builds', vmbuild])
572 tasks.append(t.stop()) 621 tasks.append(t.stop())
573 622
574 t = Task('BootstrapWithSystemAssertions:' + vmbuild) 623 t = Task('BootstrapWithSystemAssertions:' + vmbuild)
575 vm(['-esa', '-version']) 624 vm(['-esa', '-version'])
576 tasks.append(t.stop()) 625 tasks.append(t.stop())
585 t.abort(test.group + ' ' + test.name + ' Failed') 634 t.abort(test.group + ' ' + test.name + ' Failed')
586 tasks.append(t.stop()) 635 tasks.append(t.stop())
587 except KeyboardInterrupt: 636 except KeyboardInterrupt:
588 total.abort(1) 637 total.abort(1)
589 638
590 except Exception as e: 639 except BaseException as e:
591 import traceback 640 import traceback
592 traceback.print_exc() 641 traceback.print_exc()
593 total.abort(str(e)) 642 total.abort(str(e))
594 643
595 total.stop() 644 total.stop()
708 757
709 def mx_init(): 758 def mx_init():
710 _vmbuild = 'product' 759 _vmbuild = 'product'
711 commands = { 760 commands = {
712 'build': [build, '[-options]'], 761 'build': [build, '[-options]'],
762 'buildvms': [buildvms, ''],
713 'clean': [clean, ''], 763 'clean': [clean, ''],
714 'copyrightcheck': [copyrightcheck, ''], 764 'copyrightcheck': [copyrightcheck, ''],
715 'hsdis': [hsdis, '[att]'], 765 'hsdis': [hsdis, '[att]'],
716 'dacapo': [dacapo, '[[n] benchmark] [VM options|@DaCapo options]'], 766 'dacapo': [dacapo, '[[n] benchmark] [VM options|@DaCapo options]'],
717 'scaladacapo': [scaladacapo, '[[n] benchmark] [VM options|@Scala DaCapo options]'], 767 'scaladacapo': [scaladacapo, '[[n] benchmark] [VM options|@Scala DaCapo options]'],