Mercurial > hg > truffle
comparison mx/commands.py @ 4234:057620486c90
Improved time stamps of gate tasks to show duration of each task explicitly.
Added 'fastdebug' config to gate testing.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 06 Jan 2012 14:01:43 +0100 |
parents | b780ecb920c9 |
children | 23f41c48b19b |
comparison
equal
deleted
inserted
replaced
4233:fa53d5e4aa35 | 4234:057620486c90 |
---|---|
270 def build(args): | 270 def build(args): |
271 """builds the GraalVM binary and compiles the Graal classes | 271 """builds the GraalVM binary and compiles the Graal classes |
272 | 272 |
273 The optional last argument specifies what type of VM to build.""" | 273 The optional last argument specifies what type of VM to build.""" |
274 | 274 |
275 build = 'product' | 275 |
276 if len(args) != 0 and not args[0].startswith('-'): | 276 parser = ArgumentParser(prog='mx build'); |
277 build = args.pop(0) | 277 |
278 | |
279 # Call mx.build to compile the Java sources | 278 # Call mx.build to compile the Java sources |
280 opts = mx.build(args + ['--source', '1.7']) | 279 opts = mx.build(['--source', '1.7'] + args, parser=parser) |
281 | 280 |
282 if not _vmSourcesAvailable or not opts.native: | 281 if not _vmSourcesAvailable or not opts.native: |
283 return | 282 return |
284 | 283 |
285 jdk = _jdk(build, True) | 284 builds = opts.remainder |
286 if build == 'debug': | 285 if len(builds) == 0: |
287 build = 'jvmg' | 286 builds = ['product'] |
288 | 287 |
289 graalVmDir = join(jdk, 'jre', 'lib', 'amd64', 'graal') | 288 for build in builds: |
290 if not exists(graalVmDir): | 289 |
291 mx.log('Creating Graal directory in JDK7: ' + graalVmDir) | 290 jdk = _jdk(build, True) |
292 os.makedirs(graalVmDir) | 291 if build == 'debug': |
293 | 292 build = 'jvmg' |
294 def filterXusage(line): | 293 |
295 if not 'Xusage.txt' in line: | 294 graalVmDir = join(jdk, 'jre', 'lib', 'amd64', 'graal') |
296 sys.stderr.write(line + os.linesep) | 295 if not exists(graalVmDir): |
297 | 296 mx.log('Creating Graal directory in JDK7: ' + graalVmDir) |
298 if platform.system() == 'Windows': | 297 os.makedirs(graalVmDir) |
299 compilelogfile = _graal_home + '/graalCompile.log' | 298 |
300 _runInDebugShell('msbuild ' + _graal_home + r'\build\vs-amd64\jvm.vcproj /p:Configuration=compiler1_product /target:clean', _graal_home) | 299 def filterXusage(line): |
301 winCompileCmd = r'set HotSpotMksHome=' + _mksHome + r'& set OUT_DIR=' + jdk + r'& set JAVA_HOME=' + jdk + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' +_graal_home + r'\make\windows"& call create.bat ' + _graal_home + '' | 300 if not 'Xusage.txt' in line: |
302 print(winCompileCmd) | 301 sys.stderr.write(line + os.linesep) |
303 winCompileSuccess = re.compile(r"^Writing \.vcxproj file:") | 302 |
304 if not _runInDebugShell(winCompileCmd, _graal_home, compilelogfile, winCompileSuccess): | 303 if platform.system() == 'Windows': |
305 mx.log('Error executing create command') | 304 compilelogfile = _graal_home + '/graalCompile.log' |
306 return | 305 _runInDebugShell('msbuild ' + _graal_home + r'\build\vs-amd64\jvm.vcproj /p:Configuration=compiler1_product /target:clean', _graal_home) |
307 winBuildCmd = 'msbuild ' + _graal_home + r'\build\vs-amd64\jvm.vcxproj /p:Configuration=compiler1_product /p:Platform=x64' | 306 winCompileCmd = r'set HotSpotMksHome=' + _mksHome + r'& set OUT_DIR=' + jdk + r'& set JAVA_HOME=' + jdk + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' +_graal_home + r'\make\windows"& call create.bat ' + _graal_home + '' |
308 winBuildSuccess = re.compile('Build succeeded.') | 307 print(winCompileCmd) |
309 if not _runInDebugShell(winBuildCmd, _graal_home, compilelogfile, winBuildSuccess): | 308 winCompileSuccess = re.compile(r"^Writing \.vcxproj file:") |
310 mx.log('Error building project') | 309 if not _runInDebugShell(winCompileCmd, _graal_home, compilelogfile, winCompileSuccess): |
311 return | 310 mx.log('Error executing create command') |
312 else: | 311 return |
313 env = os.environ | 312 winBuildCmd = 'msbuild ' + _graal_home + r'\build\vs-amd64\jvm.vcxproj /p:Configuration=compiler1_product /p:Platform=x64' |
314 env.setdefault('ARCH_DATA_MODEL', '64') | 313 winBuildSuccess = re.compile('Build succeeded.') |
315 env.setdefault('LANG', 'C') | 314 if not _runInDebugShell(winBuildCmd, _graal_home, compilelogfile, winBuildSuccess): |
316 env.setdefault('HOTSPOT_BUILD_JOBS', '3') | 315 mx.log('Error building project') |
317 env.setdefault('ALT_BOOTDIR', jdk) | 316 return |
318 env.setdefault('INSTALL', 'y') | 317 else: |
319 mx.run([mx.gmake_cmd(), build + 'graal'], cwd=join(_graal_home, 'make'), err=filterXusage) | 318 env = os.environ |
319 env.setdefault('ARCH_DATA_MODEL', '64') | |
320 env.setdefault('LANG', 'C') | |
321 env.setdefault('HOTSPOT_BUILD_JOBS', '3') | |
322 env.setdefault('ALT_BOOTDIR', jdk) | |
323 env.setdefault('INSTALL', 'y') | |
324 mx.run([mx.gmake_cmd(), build + 'graal'], cwd=join(_graal_home, 'make'), err=filterXusage) | |
320 | 325 |
321 def vm(args, vm='-graal', nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, vmbuild=None): | 326 def vm(args, vm='-graal', nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, vmbuild=None): |
322 """run the GraalVM""" | 327 """run the GraalVM""" |
323 | 328 |
324 build = vmbuild if vmbuild is not None else _vmbuild if _vmSourcesAvailable else 'product' | 329 build = vmbuild if vmbuild is not None else _vmbuild if _vmSourcesAvailable else 'product' |
522 """run the tests used to validate a push | 527 """run the tests used to validate a push |
523 | 528 |
524 If this commands exits with a 0 exit code, then the source code is in | 529 If this commands exits with a 0 exit code, then the source code is in |
525 a state that would be accepted for integration into the main repository.""" | 530 a state that would be accepted for integration into the main repository.""" |
526 | 531 |
527 start = time.time() | 532 class Task: |
528 | 533 def __init__(self, title): |
529 # 1. Clean (cleaning of native code disabled as gate machine takes too long to do a clean HotSpot build) | 534 self.start = time.time() |
530 clean(['--no-native']) | 535 self.title = title |
531 | 536 mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: BEGIN: ') + title) |
532 # 2. Checkstyle | 537 def stop(self): |
533 mx.log(time.strftime('%d %b %Y %H:%M:%S - Running Checkstyle...')) | 538 duration = datetime.timedelta(seconds=time.time() - self.start) |
534 if mx.checkstyle([]) != 0: | 539 mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: END: ') + self.title + ' [' + str(duration) + ']') |
535 mx.abort('Checkstyle warnings were found') | 540 def abort(self, codeOrMessage): |
536 | 541 duration = datetime.timedelta(seconds=time.time() - self.start) |
537 # 3. Canonical mx/projects | 542 mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: ABORT: ') + self.title + ' [' + str(duration) + ']') |
538 mx.log(time.strftime('%d %b %Y %H:%M:%S - Ensuring mx/projects files are canonicalized...')) | 543 mx.abort(codeOrMessage) |
539 if mx.canonicalizeprojects([]) != 0: | 544 |
540 mx.abort('Rerun "mx canonicalizeprojects" and check-in the modified mx/projects files.') | 545 total = Task('Gate') |
541 | 546 try: |
542 # 4. Build | 547 |
543 mx.log(time.strftime('%d %b %Y %H:%M:%S - Build...')) | 548 #t = Task('CleanJava') |
544 build([]) | 549 #clean(['--no-native']) |
545 | 550 #t.stop() |
546 # 5 Copyright check (disabled until the copyrght notices in the HotSpot source files are supported by the CheckCopyright tool) | 551 |
547 #mx.log(time.strftime('%d %b %Y %H:%M:%S - Running copyright check...')) | 552 t = Task('Checkstyle') |
548 #hgNode = mx.get_env('hg_node') | 553 if mx.checkstyle([]) != 0: |
549 #if hgNode is None: | 554 t.abort('Checkstyle warnings were found') |
550 # copyrightcheck(['-modified', '-reporterrors=true', '-continueonerror']) | 555 t.stop() |
551 #else: | 556 |
552 # revTip = int(subprocess.check_output(['hg', 'tip', '--template', "'{rev}'"]).strip("'")) | 557 t = Task('Canonicalization Check') |
553 # revLast = int(subprocess.check_output(['hg', 'log', '-r', hgNode, '--template', "'{rev}'"]).strip("'")) | 558 mx.log(time.strftime('%d %b %Y %H:%M:%S - Ensuring mx/projects files are canonicalized...')) |
554 # changesetCount = revTip - revLast + 1 | 559 if mx.canonicalizeprojects([]) != 0: |
555 # mx.log(time.strftime('Checking ' + str(changesetCount) + ' changesets...')) | 560 t.abort('Rerun "mx canonicalizeprojects" and check-in the modified mx/projects files.') |
556 # copyrightcheck(['-last=' + str(changesetCount), '-reporterrors=true', '-continueonerror']) | 561 t.stop() |
557 | 562 |
558 # 6. Bootstrap with system assertions enabled | 563 t = Task('BuildJava') |
559 mx.log(time.strftime('%d %b %Y %H:%M:%S - Bootstrap with -esa...')) | 564 build(['--no-native']) |
560 vm(['-esa', '-version']) | 565 t.stop() |
561 | 566 |
562 # 7. Run unittests | 567 for vmbuild in ['product', 'fastdebug']: |
563 mx.log(time.strftime('%d %b %Y %H:%M:%S - Running unit tests...')) | 568 global _vmbuild |
564 unittest([]) | 569 _vmbuild = vmbuild |
565 | 570 |
566 # 8. Run selected DaCapo benchmarks | 571 t = Task('BuildHotSpot:' + vmbuild) |
567 mx.log(time.strftime('%d %b %Y %H:%M:%S - Running DaCapo benchmarks...')) | 572 build(['--no-java', vmbuild]) |
568 for test in sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Gate): | 573 t.stop() |
569 if not test.test('-graal'): | 574 |
570 mx.abort(test.group + ' ' + test.name + ' Failed') | 575 t = Task('BootstrapWithSystemAssertions:' + vmbuild) |
571 | 576 vm(['-esa', '-version']) |
572 duration = datetime.timedelta(seconds=time.time() - start) | 577 t.stop() |
573 mx.log(time.strftime('%d %b %Y %H:%M:%S - Gate done (duration - ' + str(duration) + ')')) | 578 |
579 t = Task('UnitTests:' + vmbuild) | |
580 unittest([]) | |
581 t.stop() | |
582 | |
583 t = Task('DaCapoBenchmarks:' + vmbuild) | |
584 for test in sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Gate): | |
585 if not test.test('-graal'): | |
586 t.abort(test.group + ' ' + test.name + ' Failed') | |
587 t.stop() | |
588 except Exception as e: | |
589 total.abort(str(e)) | |
590 | |
591 total.stop() | |
574 | 592 |
575 def bench(args): | 593 def bench(args): |
576 results = {} | 594 results = {} |
577 #DaCapo | 595 #DaCapo |
578 benchmarks = sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Benchmark) | 596 benchmarks = sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Benchmark) |
612 mx.add_argument('--fastdebug', action='store_const', dest='vmbuild', const='fastdebug', help='select the fast debug VM') | 630 mx.add_argument('--fastdebug', action='store_const', dest='vmbuild', const='fastdebug', help='select the fast debug VM') |
613 mx.add_argument('--optimized', action='store_const', dest='vmbuild', const='optimized', help='select the optimized VM') | 631 mx.add_argument('--optimized', action='store_const', dest='vmbuild', const='optimized', help='select the optimized VM') |
614 | 632 |
615 commands.update({ | 633 commands.update({ |
616 'export': [export, '[-options] [zipfile]'], | 634 'export': [export, '[-options] [zipfile]'], |
617 'build': [build, '[-options] [product|debug|fastdebug|optimized]'] | 635 'build': [build, '[-options] [product|debug|fastdebug|optimized]...'] |
618 }) | 636 }) |
619 | 637 |
620 mx.commands.update(commands) | 638 mx.commands.update(commands) |
621 | 639 |
622 def mx_post_parse_cmd_line(opts): | 640 def mx_post_parse_cmd_line(opts): |