| OLD | NEW |
| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 if (argument == '--output-type=dart') { | 102 if (argument == '--output-type=dart') { |
| 103 outputLanguage = OUTPUT_LANGUAGE_DART; | 103 outputLanguage = OUTPUT_LANGUAGE_DART; |
| 104 if (!explicitOut) { | 104 if (!explicitOut) { |
| 105 out = cwd.resolve('out.dart'); | 105 out = cwd.resolve('out.dart'); |
| 106 sourceMapOut = cwd.resolve('out.dart.map'); | 106 sourceMapOut = cwd.resolve('out.dart.map'); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 passThrough(argument); | 109 passThrough(argument); |
| 110 } | 110 } |
| 111 | 111 |
| 112 String getDepsOutput(Map<String, SourceFile> sourceFiles) { |
| 113 var filenames = new List.from(sourceFiles.keys); |
| 114 filenames.sort(); |
| 115 return Strings.join(filenames, "\n"); |
| 116 } |
| 117 |
| 112 setStrip(String argument) { | 118 setStrip(String argument) { |
| 113 stripArgumentSet = true; | 119 stripArgumentSet = true; |
| 114 passThrough(argument); | 120 passThrough(argument); |
| 115 } | 121 } |
| 116 | 122 |
| 117 handleShortOptions(String argument) { | 123 handleShortOptions(String argument) { |
| 118 var shortOptions = argument.substring(1).splitChars(); | 124 var shortOptions = argument.substring(1).splitChars(); |
| 119 for (var shortOption in shortOptions) { | 125 for (var shortOption in shortOptions) { |
| 120 switch (shortOption) { | 126 switch (shortOption) { |
| 121 case 'v': | 127 case 'v': |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // directly. In effect, we don't support truly asynchronous API. | 282 // directly. In effect, we don't support truly asynchronous API. |
| 277 String code = api.compile(uri, libraryRoot, packageRoot, provider, handler, | 283 String code = api.compile(uri, libraryRoot, packageRoot, provider, handler, |
| 278 options).value; | 284 options).value; |
| 279 if (code == null) { | 285 if (code == null) { |
| 280 fail('Error: Compilation failed.'); | 286 fail('Error: Compilation failed.'); |
| 281 } | 287 } |
| 282 String sourceMapFileName = | 288 String sourceMapFileName = |
| 283 sourceMapOut.path.substring(sourceMapOut.path.lastIndexOf('/') + 1); | 289 sourceMapOut.path.substring(sourceMapOut.path.lastIndexOf('/') + 1); |
| 284 code = '$code\n//@ sourceMappingURL=${sourceMapFileName}'; | 290 code = '$code\n//@ sourceMappingURL=${sourceMapFileName}'; |
| 285 writeString(out, code); | 291 writeString(out, code); |
| 292 writeString(new Uri.fromString('$out.deps'), getDepsOutput(sourceFiles)); |
| 286 int bytesWritten = code.length; | 293 int bytesWritten = code.length; |
| 287 info('compiled $dartBytesRead bytes Dart -> $bytesWritten bytes ' | 294 info('compiled $dartBytesRead bytes Dart -> $bytesWritten bytes ' |
| 288 '$outputLanguage in ${relativize(cwd, out, isWindows)}'); | 295 '$outputLanguage in ${relativize(cwd, out, isWindows)}'); |
| 289 if (!explicitOut) { | 296 if (!explicitOut) { |
| 290 String input = uriPathToNative(arguments[0]); | 297 String input = uriPathToNative(arguments[0]); |
| 291 String output = relativize(cwd, out, isWindows); | 298 String output = relativize(cwd, out, isWindows); |
| 292 print('Dart file $input compiled to $outputLanguage: $output'); | 299 print('Dart file $input compiled to $outputLanguage: $output'); |
| 293 } | 300 } |
| 294 } | 301 } |
| 295 | 302 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 } catch (ignored) { | 433 } catch (ignored) { |
| 427 print('Internal error: error while printing exception'); | 434 print('Internal error: error while printing exception'); |
| 428 } | 435 } |
| 429 try { | 436 try { |
| 430 print(trace); | 437 print(trace); |
| 431 } finally { | 438 } finally { |
| 432 exit(253); // 253 is recognized as a crash by our test scripts. | 439 exit(253); // 253 is recognized as a crash by our test scripts. |
| 433 } | 440 } |
| 434 } | 441 } |
| 435 } | 442 } |
| OLD | NEW |