Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/dart2js.dart

Issue 80793002: Check compiler exitCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 import 'dart:io' 9 import 'dart:io'
9 show exit, File, FileMode, Platform, RandomAccessFile; 10 show exit, File, FileMode, Platform, RandomAccessFile;
10 import 'dart:math' as math; 11 import 'dart:math' as math;
11 12
12 import '../compiler.dart' as api; 13 import '../compiler.dart' as api;
13 import 'source_file.dart'; 14 import 'source_file.dart';
14 import 'source_file_provider.dart'; 15 import 'source_file_provider.dart';
15 import 'filenames.dart'; 16 import 'filenames.dart';
16 import 'util/uri_extras.dart'; 17 import 'util/uri_extras.dart';
17 import 'util/util.dart'; 18 import 'util/util.dart';
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 412 }
412 output.closeSync(); 413 output.closeSync();
413 if (isPrimaryOutput) { 414 if (isPrimaryOutput) {
414 totalCharactersWritten += charactersWritten; 415 totalCharactersWritten += charactersWritten;
415 } 416 }
416 } 417 }
417 418
418 return new EventSinkWrapper(writeStringSync, onDone); 419 return new EventSinkWrapper(writeStringSync, onDone);
419 } 420 }
420 421
421 return api.compile(uri, libraryRoot, packageRoot, 422 return compileFunc(uri, libraryRoot, packageRoot,
422 inputProvider, diagnosticHandler, 423 inputProvider, diagnosticHandler,
423 options, outputProvider, environment) 424 options, outputProvider, environment)
424 .then(compilationDone); 425 .then(compilationDone);
425 } 426 }
426 427
427 class EventSinkWrapper extends EventSink<String> { 428 class EventSinkWrapper extends EventSink<String> {
428 var onAdd, onClose; 429 var onAdd, onClose;
429 430
430 EventSinkWrapper(this.onAdd, this.onClose); 431 EventSinkWrapper(this.onAdd, this.onClose);
431 432
432 void add(String data) => onAdd(data); 433 void add(String data) => onAdd(data);
433 434
(...skipping 17 matching lines...) Expand all
451 file.closeSync(); 452 file.closeSync();
452 } 453 }
453 454
454 void fail(String message) { 455 void fail(String message) {
455 if (diagnosticHandler != null) { 456 if (diagnosticHandler != null) {
456 diagnosticHandler.diagnosticHandler( 457 diagnosticHandler.diagnosticHandler(
457 null, -1, -1, message, api.Diagnostic.ERROR); 458 null, -1, -1, message, api.Diagnostic.ERROR);
458 } else { 459 } else {
459 print(message); 460 print(message);
460 } 461 }
461 exit(1); 462 exitFunc(1);
462 } 463 }
463 464
464 Future compilerMain(List<String> arguments) { 465 Future compilerMain(List<String> arguments) {
465 var root = uriPathToNative("/$LIBRARY_ROOT"); 466 var root = uriPathToNative("/$LIBRARY_ROOT");
466 arguments = <String>['--library-root=${Platform.script.toFilePath()}$root'] 467 arguments = <String>['--library-root=${Platform.script.toFilePath()}$root']
467 ..addAll(arguments); 468 ..addAll(arguments);
468 return compile(arguments); 469 return compile(arguments);
469 } 470 }
470 471
471 void help() { 472 void help() {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 : BUILD_ID; 586 : BUILD_ID;
586 print('Dart-to-JavaScript compiler (dart2js) version: $version'); 587 print('Dart-to-JavaScript compiler (dart2js) version: $version');
587 } 588 }
588 if (wantHelp) { 589 if (wantHelp) {
589 if (verbose) { 590 if (verbose) {
590 verboseHelp(); 591 verboseHelp();
591 } else { 592 } else {
592 help(); 593 help();
593 } 594 }
594 } 595 }
595 exit(0); 596 exitFunc(0);
596 } 597 }
597 598
598 void helpAndFail(String message) { 599 void helpAndFail(String message) {
599 help(); 600 help();
600 print(''); 601 print('');
601 fail(message); 602 fail(message);
602 } 603 }
603 604
604 void main(List<String> arguments) { 605 void main(List<String> arguments) {
605 runZoned(() => compilerMain(arguments), onError: (exception, trace) { 606 internalMain(arguments);
607 }
608
609 var exitFunc = exit;
610 var compileFunc = api.compile;
611
612 Future internalMain(List<String> arguments) {
613 onError(exception, trace) {
606 try { 614 try {
607 print('Internal error: $exception'); 615 print('The compiler crashed: $exception');
608 } catch (ignored) { 616 } catch (ignored) {
609 print('Internal error: error while printing exception'); 617 print('The compiler crashed: error while printing exception');
610 } 618 }
611 619
612 try { 620 try {
613 if (trace != null) { 621 if (trace != null) {
614 print(trace); 622 print(trace);
615 } 623 }
616 } finally { 624 } finally {
617 exit(253); // 253 is recognized as a crash by our test scripts. 625 exitFunc(253); // 253 is recognized as a crash by our test scripts.
618 } 626 }
619 }); 627 }
628
629 try {
630 return compilerMain(arguments).catchError(onError);
631 } catch (exception, trace) {
632 onError(exception, trace);
633 return new Future.value();
634 }
620 } 635 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/compiler.dart ('k') | sdk/lib/_internal/compiler/implementation/util/util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698