Chromium Code Reviews| 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:convert' show UTF8, LineSplitter; | 9 import 'dart:convert' show UTF8, LineSplitter; |
| 10 import 'dart:io' | 10 import 'dart:io' |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 Uri sourceMapOut = currentDirectory.resolve('out.js.map'); | 107 Uri sourceMapOut = currentDirectory.resolve('out.js.map'); |
| 108 Uri packageRoot = null; | 108 Uri packageRoot = null; |
| 109 List<String> options = new List<String>(); | 109 List<String> options = new List<String>(); |
| 110 bool explicitOut = false; | 110 bool explicitOut = false; |
| 111 bool wantHelp = false; | 111 bool wantHelp = false; |
| 112 bool wantVersion = false; | 112 bool wantVersion = false; |
| 113 String outputLanguage = 'JavaScript'; | 113 String outputLanguage = 'JavaScript'; |
| 114 bool stripArgumentSet = false; | 114 bool stripArgumentSet = false; |
| 115 bool analyzeOnly = false; | 115 bool analyzeOnly = false; |
| 116 bool analyzeAll = false; | 116 bool analyzeAll = false; |
| 117 bool dumpInfo = false; | |
| 117 bool allowNativeExtensions = false; | 118 bool allowNativeExtensions = false; |
| 118 bool trustTypeAnnotations = false; | 119 bool trustTypeAnnotations = false; |
| 119 bool trustPrimitives = false; | 120 bool trustPrimitives = false; |
| 120 bool checkedMode = false; | 121 bool checkedMode = false; |
| 121 // List of provided options that imply that output is expected. | 122 // List of provided options that imply that output is expected. |
| 122 List<String> optionsImplyCompilation = <String>[]; | 123 List<String> optionsImplyCompilation = <String>[]; |
| 123 bool hasDisallowUnsafeEval = false; | 124 bool hasDisallowUnsafeEval = false; |
| 124 // TODO(johnniwinther): Measure time for reading files. | 125 // TODO(johnniwinther): Measure time for reading files. |
| 125 SourceFileProvider inputProvider = new CompilerSourceFileProvider(); | 126 SourceFileProvider inputProvider = new CompilerSourceFileProvider(); |
| 126 diagnosticHandler = new FormattingDiagnosticHandler(inputProvider); | 127 diagnosticHandler = new FormattingDiagnosticHandler(inputProvider); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 setVerbose(_) { | 200 setVerbose(_) { |
| 200 diagnosticHandler.verbose = true; | 201 diagnosticHandler.verbose = true; |
| 201 passThrough('--verbose'); | 202 passThrough('--verbose'); |
| 202 } | 203 } |
| 203 | 204 |
| 204 implyCompilation(String argument) { | 205 implyCompilation(String argument) { |
| 205 optionsImplyCompilation.add(argument); | 206 optionsImplyCompilation.add(argument); |
| 206 passThrough(argument); | 207 passThrough(argument); |
| 207 } | 208 } |
| 208 | 209 |
| 210 setDumpInfo(String argument) { | |
| 211 implyCompilation(argument); | |
| 212 dumpInfo = true; | |
| 213 } | |
| 214 | |
| 209 setTrustTypeAnnotations(String argument) { | 215 setTrustTypeAnnotations(String argument) { |
| 210 trustTypeAnnotations = true; | 216 trustTypeAnnotations = true; |
| 211 implyCompilation(argument); | 217 implyCompilation(argument); |
| 212 } | 218 } |
| 213 | 219 |
| 214 setTrustPrimitives(String argument) { | 220 setTrustPrimitives(String argument) { |
| 215 trustPrimitives = true; | 221 trustPrimitives = true; |
| 216 implyCompilation(argument); | 222 implyCompilation(argument); |
| 217 } | 223 } |
| 218 | 224 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true), | 327 new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true), |
| 322 new OptionHandler('--package-root=.+|-p.+', setPackageRoot), | 328 new OptionHandler('--package-root=.+|-p.+', setPackageRoot), |
| 323 new OptionHandler('--analyze-all', setAnalyzeAll), | 329 new OptionHandler('--analyze-all', setAnalyzeAll), |
| 324 new OptionHandler('--analyze-only', setAnalyzeOnly), | 330 new OptionHandler('--analyze-only', setAnalyzeOnly), |
| 325 new OptionHandler('--analyze-signatures-only', setAnalyzeOnly), | 331 new OptionHandler('--analyze-signatures-only', setAnalyzeOnly), |
| 326 new OptionHandler('--disable-native-live-type-analysis', passThrough), | 332 new OptionHandler('--disable-native-live-type-analysis', passThrough), |
| 327 new OptionHandler('--categories=.*', setCategories), | 333 new OptionHandler('--categories=.*', setCategories), |
| 328 new OptionHandler('--disable-type-inference', implyCompilation), | 334 new OptionHandler('--disable-type-inference', implyCompilation), |
| 329 new OptionHandler('--terse', passThrough), | 335 new OptionHandler('--terse', passThrough), |
| 330 new OptionHandler('--deferred-map=.+', implyCompilation), | 336 new OptionHandler('--deferred-map=.+', implyCompilation), |
| 331 new OptionHandler('--dump-info', implyCompilation), | 337 new OptionHandler('--dump-info', setDumpInfo), |
| 332 new OptionHandler('--disallow-unsafe-eval', | 338 new OptionHandler('--disallow-unsafe-eval', |
| 333 (_) => hasDisallowUnsafeEval = true), | 339 (_) => hasDisallowUnsafeEval = true), |
| 334 new OptionHandler('--show-package-warnings', passThrough), | 340 new OptionHandler('--show-package-warnings', passThrough), |
| 335 new OptionHandler('--csp', passThrough), | 341 new OptionHandler('--csp', passThrough), |
| 336 new OptionHandler('--enable-experimental-mirrors', passThrough), | 342 new OptionHandler('--enable-experimental-mirrors', passThrough), |
| 337 new OptionHandler('--enable-async', (_) { | 343 new OptionHandler('--enable-async', (_) { |
| 338 diagnosticHandler.info( | 344 diagnosticHandler.info( |
| 339 "Option '--enable-async' is no longer needed. " | 345 "Option '--enable-async' is no longer needed. " |
| 340 "Async-await is supported by default.", | 346 "Async-await is supported by default.", |
| 341 api.Diagnostic.HINT); | 347 api.Diagnostic.HINT); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 "but compilation is turned off by the option '--analyze-only'.", | 413 "but compilation is turned off by the option '--analyze-only'.", |
| 408 api.Diagnostic.INFO); | 414 api.Diagnostic.INFO); |
| 409 } | 415 } |
| 410 if (analyzeAll) analyzeOnly = true; | 416 if (analyzeAll) analyzeOnly = true; |
| 411 if (!analyzeOnly) { | 417 if (!analyzeOnly) { |
| 412 if (allowNativeExtensions) { | 418 if (allowNativeExtensions) { |
| 413 helpAndFail("Option '--allow-native-extensions' is only supported in " | 419 helpAndFail("Option '--allow-native-extensions' is only supported in " |
| 414 "combination with the '--analyze-only' option."); | 420 "combination with the '--analyze-only' option."); |
| 415 } | 421 } |
| 416 } | 422 } |
| 423 if (dumpInfo && outputLanguage == OUTPUT_LANGUAGE_DART) { | |
| 424 helpAndFail("Option '--dump-info' is not supported in " | |
| 425 "combination with the '--output-type=dart' option."); | |
| 426 } | |
| 417 | 427 |
| 418 diagnosticHandler.info('Package root is $packageRoot'); | 428 diagnosticHandler.info('Package root is $packageRoot'); |
| 419 | 429 |
| 420 options.add('--out=$out'); | 430 options.add('--out=$out'); |
| 421 options.add('--source-map=$sourceMapOut'); | 431 options.add('--source-map=$sourceMapOut'); |
| 422 | 432 |
| 423 RandomAccessFileOutputProvider outputProvider = | 433 RandomAccessFileOutputProvider outputProvider = |
| 424 new RandomAccessFileOutputProvider( | 434 new RandomAccessFileOutputProvider( |
| 425 out, sourceMapOut, onInfo: diagnosticHandler.info, onFailure: fail); | 435 out, sourceMapOut, onInfo: diagnosticHandler.info, onFailure: fail); |
| 426 | 436 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 598 unsupported category, for example, --categories=help. To enable | 608 unsupported category, for example, --categories=help. To enable |
| 599 all categories, use --categories=all. | 609 all categories, use --categories=all. |
| 600 | 610 |
| 601 --deferred-map=<file> | 611 --deferred-map=<file> |
| 602 Generates a json file with a mapping from each deferred import to a list of | 612 Generates a json file with a mapping from each deferred import to a list of |
| 603 the part.js files that will be loaded. | 613 the part.js files that will be loaded. |
| 604 | 614 |
| 605 --dump-info | 615 --dump-info |
| 606 Generates an out.info.json file with information about the generated code. | 616 Generates an out.info.json file with information about the generated code. |
| 607 You can inspect the generated file with the viewer at: | 617 You can inspect the generated file with the viewer at: |
| 608 https://dart-lang.github.io/dump-info-visualizer/ | 618 https://dart-lang.github.io/dump-info-visualizer/ |
| 619 This is features is currently not supported in combination with the | |
|
floitsch
2015/03/09 15:06:21
s/This is/This/
Johnni Winther
2015/03/11 13:08:44
Done.
| |
| 620 '--output-type=dart' option. | |
| 609 | 621 |
| 610 --generate-code-with-compile-time-errors | 622 --generate-code-with-compile-time-errors |
| 611 Generates output even if the program contains compile-time errors. Use the | 623 Generates output even if the program contains compile-time errors. Use the |
| 612 exit code to determine if compilation failed. | 624 exit code to determine if compilation failed. |
| 613 '''.trim()); | 625 '''.trim()); |
| 614 } | 626 } |
| 615 | 627 |
| 616 void helpAndExit(bool wantHelp, bool wantVersion, bool verbose) { | 628 void helpAndExit(bool wantHelp, bool wantVersion, bool verbose) { |
| 617 if (wantVersion) { | 629 if (wantVersion) { |
| 618 var version = (BUILD_ID == null) | 630 var version = (BUILD_ID == null) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 717 } else if (exitCode == 253) { | 729 } else if (exitCode == 253) { |
| 718 print(">>> TEST CRASH"); | 730 print(">>> TEST CRASH"); |
| 719 } else { | 731 } else { |
| 720 print(">>> TEST FAIL"); | 732 print(">>> TEST FAIL"); |
| 721 } | 733 } |
| 722 stderr.writeln(">>> EOF STDERR"); | 734 stderr.writeln(">>> EOF STDERR"); |
| 723 subscription.resume(); | 735 subscription.resume(); |
| 724 }); | 736 }); |
| 725 }); | 737 }); |
| 726 } | 738 } |
| OLD | NEW |