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

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

Issue 10331010: Add support for --no-colors to make it easier to integrate dart2js in the editor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add bug number. Created 8 years, 7 months 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
« no previous file with comments | « lib/compiler/implementation/colors.dart ('k') | lib/compiler/implementation/source_file.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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'); 5 #library('dart2js');
6 6
7 #import('dart:io'); 7 #import('dart:io');
8 #import('dart:uri'); 8 #import('dart:uri');
9 #import('dart:utf'); 9 #import('dart:utf');
10 10
11 #import('../compiler.dart', prefix: 'api'); 11 #import('../compiler.dart', prefix: 'api');
12 #import('colors.dart'); 12 #import('colors.dart', prefix: 'colors');
13 #import('source_file.dart'); 13 #import('source_file.dart');
14 #import('filenames.dart'); 14 #import('filenames.dart');
15 #import('util/uri_extras.dart'); 15 #import('util/uri_extras.dart');
16 16
17 final String LIBRARY_ROOT = '../../../..'; 17 final String LIBRARY_ROOT = '../../../..';
18 18
19 void compile(List<String> argv) { 19 void compile(List<String> argv) {
20 Uri cwd = getCurrentDirectory(); 20 Uri cwd = getCurrentDirectory();
21 bool throwOnError = false; 21 bool throwOnError = false;
22 bool showWarnings = true; 22 bool showWarnings = true;
(...skipping 14 matching lines...) Expand all
37 String path = 37 String path =
38 nativeToUriPath(argument.substring(argument.indexOf('=') + 1)); 38 nativeToUriPath(argument.substring(argument.indexOf('=') + 1));
39 if (!path.endsWith("/")) path = "$path/"; 39 if (!path.endsWith("/")) path = "$path/";
40 libraryRoot = cwd.resolve(path); 40 libraryRoot = cwd.resolve(path);
41 } else if (argument.startsWith('--out=')) { 41 } else if (argument.startsWith('--out=')) {
42 String path = 42 String path =
43 nativeToUriPath(argument.substring(argument.indexOf('=') + 1)); 43 nativeToUriPath(argument.substring(argument.indexOf('=') + 1));
44 out = cwd.resolve(path); 44 out = cwd.resolve(path);
45 } else if ('--allow-mock-compilation' == argument) { 45 } else if ('--allow-mock-compilation' == argument) {
46 options.add(argument); 46 options.add(argument);
47 } else if ('--no-colors' == argument) {
48 colors.enabled = false;
47 } else if (argument.startsWith('-')) { 49 } else if (argument.startsWith('-')) {
48 fail('Unknown option $argument.'); 50 fail('Unknown option $argument.');
49 } else { 51 } else {
50 arguments.add(nativeToUriPath(argument)); 52 arguments.add(nativeToUriPath(argument));
51 } 53 }
52 } 54 }
53 if (arguments.isEmpty()) { 55 if (arguments.isEmpty()) {
54 fail('No file to compile.'); 56 fail('No file to compile.');
55 } 57 }
56 if (arguments.length > 1) { 58 if (arguments.length > 1) {
(...skipping 11 matching lines...) Expand all
68 String source = readAll(uriPathToNative(uri.path)); 70 String source = readAll(uriPathToNative(uri.path));
69 dartBytesRead += source.length; 71 dartBytesRead += source.length;
70 sourceFiles[uri.toString()] = 72 sourceFiles[uri.toString()] =
71 new SourceFile(relativize(cwd, uri), source); 73 new SourceFile(relativize(cwd, uri), source);
72 Completer<String> completer = new Completer<String>(); 74 Completer<String> completer = new Completer<String>();
73 completer.complete(source); 75 completer.complete(source);
74 return completer.future; 76 return completer.future;
75 } 77 }
76 78
77 void info(var message) { 79 void info(var message) {
78 if (verbose) print('${green("info:")} $message'); 80 if (verbose) print('${colors.green("info:")} $message');
79 } 81 }
80 82
81 void handler(Uri uri, int begin, int end, String message, bool fatal) { 83 void handler(Uri uri, int begin, int end, String message, bool fatal) {
82 if (uri === null && !fatal) { 84 if (uri === null && !fatal) {
83 info(message); 85 info(message);
84 return; 86 return;
85 } 87 }
86 if (uri === null) { 88 if (uri === null) {
87 assert(fatal); 89 assert(fatal);
88 print(message); 90 print(message);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } catch (var ignored) { 155 } catch (var ignored) {
154 print('Internal error: error while printing exception'); 156 print('Internal error: error while printing exception');
155 } 157 }
156 try { 158 try {
157 print(trace); 159 print(trace);
158 } finally { 160 } finally {
159 exit(253); // 253 is recognized as a crash by our test scripts. 161 exit(253); // 253 is recognized as a crash by our test scripts.
160 } 162 }
161 } 163 }
162 } 164 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/colors.dart ('k') | lib/compiler/implementation/source_file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698