| 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' show Future; | 7 import 'dart:async' show Future; |
| 8 import 'dart:convert' show UTF8, LineSplitter; | 8 import 'dart:convert' show UTF8, LineSplitter; |
| 9 import 'dart:io' show exit, File, FileMode, Platform, stdin, stderr; | 9 import 'dart:io' show exit, File, FileMode, Platform, stdin, stderr; |
| 10 | 10 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 bool allowNativeExtensions = false; | 124 bool allowNativeExtensions = false; |
| 125 bool trustTypeAnnotations = false; | 125 bool trustTypeAnnotations = false; |
| 126 bool checkedMode = false; | 126 bool checkedMode = false; |
| 127 List<String> hints = <String>[]; | 127 List<String> hints = <String>[]; |
| 128 bool verbose; | 128 bool verbose; |
| 129 bool throwOnError; | 129 bool throwOnError; |
| 130 int throwOnErrorCount; | 130 int throwOnErrorCount; |
| 131 bool showWarnings; | 131 bool showWarnings; |
| 132 bool showHints; | 132 bool showHints; |
| 133 bool enableColors; | 133 bool enableColors; |
| 134 bool loadFromDill = false; |
| 134 // List of provided options that imply that output is expected. | 135 // List of provided options that imply that output is expected. |
| 135 List<String> optionsImplyCompilation = <String>[]; | 136 List<String> optionsImplyCompilation = <String>[]; |
| 136 bool hasDisallowUnsafeEval = false; | 137 bool hasDisallowUnsafeEval = false; |
| 137 Map<String, dynamic> environment = new Map<String, dynamic>(); | 138 Map<String, dynamic> environment = new Map<String, dynamic>(); |
| 138 | 139 |
| 139 void passThrough(String argument) => options.add(argument); | 140 void passThrough(String argument) => options.add(argument); |
| 140 | 141 |
| 141 void ignoreOption(String argument) {} | 142 void ignoreOption(String argument) {} |
| 142 | 143 |
| 143 if (BUILD_ID != null) { | 144 if (BUILD_ID != null) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 for (String category in categories) { | 271 for (String category in categories) { |
| 271 if (!["Client", "Server"].contains(category)) { | 272 if (!["Client", "Server"].contains(category)) { |
| 272 fail('Unsupported library category "$category", ' | 273 fail('Unsupported library category "$category", ' |
| 273 'supported categories are: Client, Server, all'); | 274 'supported categories are: Client, Server, all'); |
| 274 } | 275 } |
| 275 } | 276 } |
| 276 } | 277 } |
| 277 passThrough('--categories=${categories.join(",")}'); | 278 passThrough('--categories=${categories.join(",")}'); |
| 278 } | 279 } |
| 279 | 280 |
| 281 void setLoadFromDill(String argument) { |
| 282 loadFromDill = true; |
| 283 passThrough(argument); |
| 284 } |
| 285 |
| 280 void handleThrowOnError(String argument) { | 286 void handleThrowOnError(String argument) { |
| 281 throwOnError = true; | 287 throwOnError = true; |
| 282 String parameter = extractParameter(argument, isOptionalArgument: true); | 288 String parameter = extractParameter(argument, isOptionalArgument: true); |
| 283 if (parameter != null) { | 289 if (parameter != null) { |
| 284 var count = int.parse(parameter); | 290 var count = int.parse(parameter); |
| 285 throwOnErrorCount = count; | 291 throwOnErrorCount = count; |
| 286 } | 292 } |
| 287 } | 293 } |
| 288 | 294 |
| 289 void handleShortOptions(String argument) { | 295 void handleShortOptions(String argument) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 showHints = false; | 328 showHints = false; |
| 323 }), | 329 }), |
| 324 // TODO(sigmund): remove entirely after Dart 1.20 | 330 // TODO(sigmund): remove entirely after Dart 1.20 |
| 325 new OptionHandler( | 331 new OptionHandler( |
| 326 '--output-type=dart|--output-type=dart-multi|--output-type=js', | 332 '--output-type=dart|--output-type=dart-multi|--output-type=js', |
| 327 setOutputType), | 333 setOutputType), |
| 328 // TODO(efortuna): Remove this once kernel global inference is fully | 334 // TODO(efortuna): Remove this once kernel global inference is fully |
| 329 // implemented. | 335 // implemented. |
| 330 new OptionHandler(Flags.kernelGlobalInference, passThrough), | 336 new OptionHandler(Flags.kernelGlobalInference, passThrough), |
| 331 new OptionHandler(Flags.useKernel, passThrough), | 337 new OptionHandler(Flags.useKernel, passThrough), |
| 332 new OptionHandler(Flags.loadFromDill, passThrough), | 338 new OptionHandler(Flags.loadFromDill, setLoadFromDill), |
| 333 new OptionHandler(Flags.noFrequencyBasedMinification, passThrough), | 339 new OptionHandler(Flags.noFrequencyBasedMinification, passThrough), |
| 334 new OptionHandler(Flags.verbose, setVerbose), | 340 new OptionHandler(Flags.verbose, setVerbose), |
| 335 new OptionHandler(Flags.version, (_) => wantVersion = true), | 341 new OptionHandler(Flags.version, (_) => wantVersion = true), |
| 336 new OptionHandler('--library-root=.+', setLibraryRoot), | 342 new OptionHandler('--library-root=.+', setLibraryRoot), |
| 337 new OptionHandler('--out=.+|-o.*', setOutput, multipleArguments: true), | 343 new OptionHandler('--out=.+|-o.*', setOutput, multipleArguments: true), |
| 338 new OptionHandler(Flags.allowMockCompilation, passThrough), | 344 new OptionHandler(Flags.allowMockCompilation, passThrough), |
| 339 new OptionHandler(Flags.fastStartup, passThrough), | 345 new OptionHandler(Flags.fastStartup, passThrough), |
| 340 new OptionHandler(Flags.genericMethodSyntax, ignoreOption), | 346 new OptionHandler(Flags.genericMethodSyntax, ignoreOption), |
| 341 new OptionHandler(Flags.initializingFormalAccess, ignoreOption), | 347 new OptionHandler(Flags.initializingFormalAccess, ignoreOption), |
| 342 new OptionHandler('${Flags.minify}|-m', implyCompilation), | 348 new OptionHandler('${Flags.minify}|-m', implyCompilation), |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 } | 453 } |
| 448 if (showHints != null) { | 454 if (showHints != null) { |
| 449 diagnosticHandler.showHints = showHints; | 455 diagnosticHandler.showHints = showHints; |
| 450 } | 456 } |
| 451 if (enableColors != null) { | 457 if (enableColors != null) { |
| 452 diagnosticHandler.enableColors = enableColors; | 458 diagnosticHandler.enableColors = enableColors; |
| 453 } | 459 } |
| 454 for (String hint in hints) { | 460 for (String hint in hints) { |
| 455 diagnosticHandler.info(hint, api.Diagnostic.HINT); | 461 diagnosticHandler.info(hint, api.Diagnostic.HINT); |
| 456 } | 462 } |
| 463 if (loadFromDill) { |
| 464 diagnosticHandler.autoReadFileUri = true; |
| 465 } |
| 457 | 466 |
| 458 if (wantHelp || wantVersion) { | 467 if (wantHelp || wantVersion) { |
| 459 helpAndExit(wantHelp, wantVersion, diagnosticHandler.verbose); | 468 helpAndExit(wantHelp, wantVersion, diagnosticHandler.verbose); |
| 460 } | 469 } |
| 461 | 470 |
| 462 if (hasDisallowUnsafeEval) { | 471 if (hasDisallowUnsafeEval) { |
| 463 String precompiledName = relativize( | 472 String precompiledName = relativize( |
| 464 currentDirectory, | 473 currentDirectory, |
| 465 RandomAccessFileOutputProvider.computePrecompiledUri(out), | 474 RandomAccessFileOutputProvider.computePrecompiledUri(out), |
| 466 Platform.isWindows); | 475 Platform.isWindows); |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 @override | 1089 @override |
| 1081 void add(String event) { | 1090 void add(String event) { |
| 1082 sb.write(event); | 1091 sb.write(event); |
| 1083 } | 1092 } |
| 1084 | 1093 |
| 1085 @override | 1094 @override |
| 1086 void close() { | 1095 void close() { |
| 1087 // Do nothing. | 1096 // Do nothing. |
| 1088 } | 1097 } |
| 1089 } | 1098 } |
| OLD | NEW |