Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.cmdline; | 5 library dart2js.cmdline; |
| 6 | 6 |
| 7 import 'dart:async' | 7 import 'dart:async' |
| 8 show Future, EventSink; | 8 show Future, EventSink; |
| 9 import 'dart:convert' show UTF8, LineSplitter; | 9 import 'dart:convert' show UTF8, LineSplitter; |
| 10 import 'dart:io' | 10 import 'dart:io' |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 options.add('--out=$out'); | 419 options.add('--out=$out'); |
| 420 options.add('--source-map=$sourceMapOut'); | 420 options.add('--source-map=$sourceMapOut'); |
| 421 | 421 |
| 422 RandomAccessFileOutputProvider outputProvider = | 422 RandomAccessFileOutputProvider outputProvider = |
| 423 new RandomAccessFileOutputProvider( | 423 new RandomAccessFileOutputProvider( |
| 424 out, sourceMapOut, onInfo: diagnosticHandler.info, onFailure: fail); | 424 out, sourceMapOut, onInfo: diagnosticHandler.info, onFailure: fail); |
| 425 | 425 |
| 426 api.CompilationResult compilationDone(api.CompilationResult result) { | 426 api.CompilationResult compilationDone(api.CompilationResult result) { |
| 427 if (analyzeOnly) return result; | 427 if (analyzeOnly) return result; |
| 428 if (!result.isSuccess) { | 428 if (!result.isSuccess) { |
| 429 fail('Compilation failed.'); | 429 fail('Compilation failed.'); |
|
ahe
2015/01/13 08:35:20
This throws _EXIT_SIGNAL.
| |
| 430 } | 430 } |
| 431 writeString(Uri.parse('$out.deps'), | 431 writeString(Uri.parse('$out.deps'), |
| 432 getDepsOutput(inputProvider.sourceFiles)); | 432 getDepsOutput(inputProvider.sourceFiles)); |
| 433 diagnosticHandler.info( | 433 diagnosticHandler.info( |
| 434 'Compiled ${inputProvider.dartCharactersRead} characters Dart ' | 434 'Compiled ${inputProvider.dartCharactersRead} characters Dart ' |
| 435 '-> ${outputProvider.totalCharactersWritten} characters ' | 435 '-> ${outputProvider.totalCharactersWritten} characters ' |
| 436 '$outputLanguage in ' | 436 '$outputLanguage in ' |
| 437 '${relativize(currentDirectory, out, Platform.isWindows)}'); | 437 '${relativize(currentDirectory, out, Platform.isWindows)}'); |
| 438 if (diagnosticHandler.verbose) { | 438 if (diagnosticHandler.verbose) { |
| 439 String input = uriPathToNative(arguments[0]); | 439 String input = uriPathToNative(arguments[0]); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 651 Future<api.CompilationResult> internalMain(List<String> arguments) { | 651 Future<api.CompilationResult> internalMain(List<String> arguments) { |
| 652 Future onError(exception, trace) { | 652 Future onError(exception, trace) { |
| 653 try { | 653 try { |
| 654 print('The compiler crashed: $exception'); | 654 print('The compiler crashed: $exception'); |
| 655 } catch (ignored) { | 655 } catch (ignored) { |
| 656 print('The compiler crashed: error while printing exception'); | 656 print('The compiler crashed: error while printing exception'); |
| 657 } | 657 } |
| 658 | 658 |
| 659 try { | 659 try { |
| 660 if (trace != null) { | 660 if (trace != null) { |
| 661 print(trace); | 661 print(trace); |
|
ahe
2015/01/13 08:35:20
This prints the stack trace associated with _EXIT_
| |
| 662 } | 662 } |
| 663 } finally { | 663 } finally { |
| 664 exitFunc(253); // 253 is recognized as a crash by our test scripts. | 664 exitFunc(253); // 253 is recognized as a crash by our test scripts. |
| 665 } | 665 } |
| 666 return new Future.error(exception, trace); | 666 return new Future.error(exception, trace); |
| 667 } | 667 } |
| 668 | 668 |
| 669 try { | 669 try { |
| 670 return compilerMain(arguments).catchError(onError); | 670 return compilerMain(arguments).catchError(onError); |
|
ahe
2015/01/13 08:35:20
This calls compile which calls compilationDone.
| |
| 671 } catch (exception, trace) { | 671 } catch (exception, trace) { |
| 672 return onError(exception, trace); | 672 return onError(exception, trace); |
| 673 } | 673 } |
| 674 } | 674 } |
| 675 | 675 |
| 676 const _EXIT_SIGNAL = const Object(); | 676 class _ExitSignal { |
| 677 const _ExitSignal(); | |
| 678 } | |
| 679 | |
| 680 const _EXIT_SIGNAL = const _ExitSignal(); | |
| 677 | 681 |
| 678 void batchMain(List<String> batchArguments) { | 682 void batchMain(List<String> batchArguments) { |
| 679 int exitCode; | 683 int exitCode; |
| 680 exitFunc = (errorCode) { | 684 exitFunc = (errorCode) { |
| 681 // Since we only throw another part of the compiler might intercept our | 685 // Since we only throw another part of the compiler might intercept our |
| 682 // exception and try to exit with a different code. | 686 // exception and try to exit with a different code. |
| 683 if (exitCode == 0) { | 687 if (exitCode == 0) { |
| 684 exitCode = errorCode; | 688 exitCode = errorCode; |
| 685 } | 689 } |
| 686 throw _EXIT_SIGNAL; | 690 throw _EXIT_SIGNAL; |
| 687 }; | 691 }; |
| 688 | 692 |
| 689 var stream = stdin.transform(UTF8.decoder).transform(new LineSplitter()); | 693 var stream = stdin.transform(UTF8.decoder).transform(new LineSplitter()); |
| 690 var subscription; | 694 var subscription; |
| 691 subscription = stream.listen((line) { | 695 subscription = stream.listen((line) { |
| 692 new Future.sync(() { | 696 new Future.sync(() { |
| 693 subscription.pause(); | 697 subscription.pause(); |
| 694 exitCode = 0; | 698 exitCode = 0; |
| 695 if (line == null) exit(0); | 699 if (line == null) exit(0); |
| 696 List<String> args = <String>[]; | 700 List<String> args = <String>[]; |
| 697 args.addAll(batchArguments); | 701 args.addAll(batchArguments); |
| 698 args.addAll(splitLine(line, windows: Platform.isWindows)); | 702 args.addAll(splitLine(line, windows: Platform.isWindows)); |
| 699 return internalMain(args); | 703 return internalMain(args); |
|
ahe
2015/01/13 08:35:20
Calling internalMain here.
| |
| 700 }).catchError((exception, trace) { | 704 }).catchError((exception, trace) { |
| 701 if (!identical(exception, _EXIT_SIGNAL)) { | 705 if (!identical(exception, _EXIT_SIGNAL)) { |
| 702 exitCode = 253; | 706 exitCode = 253; |
| 703 } | 707 } |
| 704 }).whenComplete(() { | 708 }).whenComplete(() { |
| 705 // The testing framework waits for a status line on stdout and | 709 // The testing framework waits for a status line on stdout and |
| 706 // stderr before moving to the next test. | 710 // stderr before moving to the next test. |
| 707 if (exitCode == 0){ | 711 if (exitCode == 0){ |
| 708 print(">>> TEST OK"); | 712 print(">>> TEST OK"); |
| 709 } else if (exitCode == 253) { | 713 } else if (exitCode == 253) { |
| 710 print(">>> TEST CRASH"); | 714 print(">>> TEST CRASH"); |
| 711 } else { | 715 } else { |
| 712 print(">>> TEST FAIL"); | 716 print(">>> TEST FAIL"); |
| 713 } | 717 } |
| 714 stderr.writeln(">>> EOF STDERR"); | 718 stderr.writeln(">>> EOF STDERR"); |
| 715 subscription.resume(); | 719 subscription.resume(); |
| 716 }); | 720 }); |
| 717 }); | 721 }); |
| 718 } | 722 } |
| OLD | NEW |