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:io' | 9 import 'dart:io' |
10 show exit, File, FileMode, Platform, RandomAccessFile, FileSystemException; | 10 show exit, File, FileMode, Platform, RandomAccessFile, FileSystemException; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 if (arguments.length > 1) { | 314 if (arguments.length > 1) { |
315 var extra = arguments.sublist(1); | 315 var extra = arguments.sublist(1); |
316 helpAndFail('Error: Extra arguments: ${extra.join(" ")}'); | 316 helpAndFail('Error: Extra arguments: ${extra.join(" ")}'); |
317 } | 317 } |
318 | 318 |
319 Uri uri = currentDirectory.resolve(arguments[0]); | 319 Uri uri = currentDirectory.resolve(arguments[0]); |
320 if (packageRoot == null) { | 320 if (packageRoot == null) { |
321 packageRoot = uri.resolve('./packages/'); | 321 packageRoot = uri.resolve('./packages/'); |
322 } | 322 } |
323 | 323 |
324 diagnosticHandler.info('package root is $packageRoot'); | 324 diagnosticHandler.info('Package root is $packageRoot'); |
325 | 325 |
326 int totalCharactersWritten = 0; | 326 int totalCharactersWritten = 0; |
327 | 327 |
| 328 options.add('--out=$out'); |
328 options.add('--source-map=$sourceMapOut'); | 329 options.add('--source-map=$sourceMapOut'); |
329 | 330 |
330 List<String> allOutputFiles = new List<String>(); | 331 List<String> allOutputFiles = new List<String>(); |
331 | 332 |
332 compilationDone(String code) { | 333 compilationDone(String code) { |
333 if (analyzeOnly) return; | 334 if (analyzeOnly) return; |
334 if (code == null) { | 335 if (code == null) { |
335 fail('Error: Compilation failed.'); | 336 fail('Error: Compilation failed.'); |
336 } | 337 } |
337 writeString(Uri.parse('$out.deps'), | 338 writeString(Uri.parse('$out.deps'), |
338 getDepsOutput(inputProvider.sourceFiles)); | 339 getDepsOutput(inputProvider.sourceFiles)); |
339 diagnosticHandler.info( | 340 diagnosticHandler.info( |
340 'compiled ${inputProvider.dartCharactersRead} characters Dart ' | 341 'Compiled ${inputProvider.dartCharactersRead} characters Dart ' |
341 '-> $totalCharactersWritten characters $outputLanguage ' | 342 '-> $totalCharactersWritten characters $outputLanguage ' |
342 'in ${relativize(currentDirectory, out, isWindows)}'); | 343 'in ${relativize(currentDirectory, out, isWindows)}'); |
343 if (diagnosticHandler.verbose) { | 344 if (diagnosticHandler.verbose) { |
344 String input = uriPathToNative(arguments[0]); | 345 String input = uriPathToNative(arguments[0]); |
345 print('Dart file ($input) compiled to $outputLanguage.'); | 346 print('Dart file ($input) compiled to $outputLanguage.'); |
346 print('Wrote the following files:'); | 347 print('Wrote the following files:'); |
347 for (String filename in allOutputFiles) { | 348 for (String filename in allOutputFiles) { |
348 print(" $filename"); | 349 print(" $filename"); |
349 } | 350 } |
350 } else if (!explicitOut) { | 351 } else if (!explicitOut) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 int offset = 0; | 404 int offset = 0; |
404 while (offset < data.length) { | 405 while (offset < data.length) { |
405 output.writeStringSync( | 406 output.writeStringSync( |
406 data.substring(offset, math.min(offset + chunkSize, data.length))); | 407 data.substring(offset, math.min(offset + chunkSize, data.length))); |
407 offset += chunkSize; | 408 offset += chunkSize; |
408 } | 409 } |
409 charactersWritten += data.length; | 410 charactersWritten += data.length; |
410 } | 411 } |
411 | 412 |
412 onDone() { | 413 onDone() { |
413 if (sourceMapFileName != null) { | |
414 // Using # is the new proposed standard. @ caused problems in Internet | |
415 // Explorer due to "Conditional Compilation Statements" in JScript, | |
416 // see: | |
417 // http://msdn.microsoft.com/en-us/library/7kx09ct1(v=vs.80).aspx | |
418 // About source maps, see: | |
419 // https://docs.google.com/a/google.com/document/d/1U1RGAehQwRypUTovF1KR
lpiOFze0b-_2gc6fAH0KY0k/edit | |
420 // TODO(http://dartbug.com/11914): Remove @ line. | |
421 String sourceMapTag = ''' | |
422 | |
423 //# sourceMappingURL=$sourceMapFileName | |
424 //@ sourceMappingURL=$sourceMapFileName | |
425 '''; | |
426 writeStringSync(sourceMapTag); | |
427 } | |
428 output.closeSync(); | 414 output.closeSync(); |
429 if (isPrimaryOutput) { | 415 if (isPrimaryOutput) { |
430 totalCharactersWritten += charactersWritten; | 416 totalCharactersWritten += charactersWritten; |
431 } | 417 } |
432 } | 418 } |
433 | 419 |
434 return new EventSinkWrapper(writeStringSync, onDone); | 420 return new EventSinkWrapper(writeStringSync, onDone); |
435 } | 421 } |
436 | 422 |
437 return compileFunc(uri, libraryRoot, packageRoot, | 423 return compileFunc(uri, libraryRoot, packageRoot, |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 } | 628 } |
643 } | 629 } |
644 | 630 |
645 try { | 631 try { |
646 return compilerMain(arguments).catchError(onError); | 632 return compilerMain(arguments).catchError(onError); |
647 } catch (exception, trace) { | 633 } catch (exception, trace) { |
648 onError(exception, trace); | 634 onError(exception, trace); |
649 return new Future.value(); | 635 return new Future.value(); |
650 } | 636 } |
651 } | 637 } |
OLD | NEW |