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

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

Issue 10914094: Improve [relativize] for Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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 | « no previous file | dart/lib/compiler/implementation/util/uri_extras.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
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (match[i + 1] !== null) { 58 if (match[i + 1] !== null) {
59 handlers[i].handle(argument); 59 handlers[i].handle(argument);
60 continue OUTER; 60 continue OUTER;
61 } 61 }
62 } 62 }
63 throw 'Internal error: "$argument" did not match'; 63 throw 'Internal error: "$argument" did not match';
64 } 64 }
65 } 65 }
66 66
67 void compile(List<String> argv) { 67 void compile(List<String> argv) {
68 bool isWindows = (Platform.operatingSystem == 'windows');
68 Uri cwd = getCurrentDirectory(); 69 Uri cwd = getCurrentDirectory();
69 bool throwOnError = false; 70 bool throwOnError = false;
70 bool showWarnings = true; 71 bool showWarnings = true;
71 bool verbose = false; 72 bool verbose = false;
72 Uri libraryRoot = cwd; 73 Uri libraryRoot = cwd;
73 Uri out = cwd.resolve('out.js'); 74 Uri out = cwd.resolve('out.js');
74 Uri sourceMapOut = cwd.resolve('out.js.map'); 75 Uri sourceMapOut = cwd.resolve('out.js.map');
75 Uri packageRoot = null; 76 Uri packageRoot = null;
76 List<String> options = new List<String>(); 77 List<String> options = new List<String>();
77 bool explicitOut = false; 78 bool explicitOut = false;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 int dartBytesRead = 0; 159 int dartBytesRead = 0;
159 160
160 Future<String> provider(Uri uri) { 161 Future<String> provider(Uri uri) {
161 if (uri.scheme != 'file') { 162 if (uri.scheme != 'file') {
162 throw new IllegalArgumentException(uri); 163 throw new IllegalArgumentException(uri);
163 } 164 }
164 String source; 165 String source;
165 try { 166 try {
166 source = readAll(uriPathToNative(uri.path)); 167 source = readAll(uriPathToNative(uri.path));
167 } on FileIOException catch (ex) { 168 } on FileIOException catch (ex) {
168 throw 'Error: Cannot read "${relativize(cwd, uri)}" (${ex.osError}).'; 169 throw 'Error: Cannot read "${relativize(cwd, uri, isWindows)}" '
170 '(${ex.osError}).';
169 } 171 }
170 dartBytesRead += source.length; 172 dartBytesRead += source.length;
171 sourceFiles[uri.toString()] = 173 sourceFiles[uri.toString()] =
172 new SourceFile(relativize(cwd, uri), source); 174 new SourceFile(relativize(cwd, uri, isWindows), source);
173 return new Future.immediate(source); 175 return new Future.immediate(source);
174 } 176 }
175 177
176 void info(var message, [api.Diagnostic kind = api.Diagnostic.VERBOSE_INFO]) { 178 void info(var message, [api.Diagnostic kind = api.Diagnostic.VERBOSE_INFO]) {
177 if (!verbose && kind === api.Diagnostic.VERBOSE_INFO) return; 179 if (!verbose && kind === api.Diagnostic.VERBOSE_INFO) return;
178 if (enableColors) { 180 if (enableColors) {
179 print('${colors.green("info:")} $message'); 181 print('${colors.green("info:")} $message');
180 } else { 182 } else {
181 print('info: $message'); 183 print('info: $message');
182 } 184 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // TODO(ahe): We expect the future to be complete and call value 246 // TODO(ahe): We expect the future to be complete and call value
245 // directly. In effect, we don't support truly asynchronous API. 247 // directly. In effect, we don't support truly asynchronous API.
246 String code = api.compile(uri, libraryRoot, packageRoot, provider, handler, 248 String code = api.compile(uri, libraryRoot, packageRoot, provider, handler,
247 options).value; 249 options).value;
248 if (code === null) { 250 if (code === null) {
249 fail('Error: Compilation failed.'); 251 fail('Error: Compilation failed.');
250 } 252 }
251 writeString(out, code); 253 writeString(out, code);
252 int jsBytesWritten = code.length; 254 int jsBytesWritten = code.length;
253 info('compiled $dartBytesRead bytes Dart -> $jsBytesWritten bytes JS ' 255 info('compiled $dartBytesRead bytes Dart -> $jsBytesWritten bytes JS '
254 'in ${relativize(cwd, out)}'); 256 'in ${relativize(cwd, out, isWindows)}');
255 if (!explicitOut) { 257 if (!explicitOut) {
256 String input = uriPathToNative(arguments[0]); 258 String input = uriPathToNative(arguments[0]);
257 String output = relativize(cwd, out); 259 String output = relativize(cwd, out, isWindows);
258 print('Dart file $input compiled to JavaScript: $output'); 260 print('Dart file $input compiled to JavaScript: $output');
259 } 261 }
260 } 262 }
261 263
262 class AbortLeg { 264 class AbortLeg {
263 final message; 265 final message;
264 AbortLeg(this.message); 266 AbortLeg(this.message);
265 toString() => 'Aborted due to --throw-on-error: $message'; 267 toString() => 'Aborted due to --throw-on-error: $message';
266 } 268 }
267 269
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 } catch (ignored) { 385 } catch (ignored) {
384 print('Internal error: error while printing exception'); 386 print('Internal error: error while printing exception');
385 } 387 }
386 try { 388 try {
387 print(trace); 389 print(trace);
388 } finally { 390 } finally {
389 exit(253); // 253 is recognized as a crash by our test scripts. 391 exit(253); // 253 is recognized as a crash by our test scripts.
390 } 392 }
391 } 393 }
392 } 394 }
OLDNEW
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/util/uri_extras.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698