| 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 bool useKernel = false; |
| 135 // List of provided options that imply that output is expected. | 135 // List of provided options that imply that output is expected. |
| 136 List<String> optionsImplyCompilation = <String>[]; | 136 List<String> optionsImplyCompilation = <String>[]; |
| 137 bool hasDisallowUnsafeEval = false; | 137 bool hasDisallowUnsafeEval = false; |
| 138 Map<String, dynamic> environment = new Map<String, dynamic>(); | 138 Map<String, dynamic> environment = new Map<String, dynamic>(); |
| 139 | 139 |
| 140 void passThrough(String argument) => options.add(argument); | 140 void passThrough(String argument) => options.add(argument); |
| 141 | 141 |
| 142 void ignoreOption(String argument) {} | 142 void ignoreOption(String argument) {} |
| 143 | 143 |
| 144 if (BUILD_ID != null) { | 144 if (BUILD_ID != null) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 for (String category in categories) { | 271 for (String category in categories) { |
| 272 if (!["Client", "Server"].contains(category)) { | 272 if (!["Client", "Server"].contains(category)) { |
| 273 fail('Unsupported library category "$category", ' | 273 fail('Unsupported library category "$category", ' |
| 274 'supported categories are: Client, Server, all'); | 274 'supported categories are: Client, Server, all'); |
| 275 } | 275 } |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 passThrough('--categories=${categories.join(",")}'); | 278 passThrough('--categories=${categories.join(",")}'); |
| 279 } | 279 } |
| 280 | 280 |
| 281 void setLoadFromDill(String argument) { | 281 void setPreviewDart2(String argument) { |
| 282 loadFromDill = true; | 282 useKernel = true; |
| 283 passThrough(argument); | 283 passThrough(argument); |
| 284 } | 284 } |
| 285 | 285 |
| 286 void handleThrowOnError(String argument) { | 286 void handleThrowOnError(String argument) { |
| 287 throwOnError = true; | 287 throwOnError = true; |
| 288 String parameter = extractParameter(argument, isOptionalArgument: true); | 288 String parameter = extractParameter(argument, isOptionalArgument: true); |
| 289 if (parameter != null) { | 289 if (parameter != null) { |
| 290 var count = int.parse(parameter); | 290 var count = int.parse(parameter); |
| 291 throwOnErrorCount = count; | 291 throwOnErrorCount = count; |
| 292 } | 292 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 new OptionHandler(Flags.suppressHints, (_) { | 327 new OptionHandler(Flags.suppressHints, (_) { |
| 328 showHints = false; | 328 showHints = false; |
| 329 }), | 329 }), |
| 330 // TODO(sigmund): remove entirely after Dart 1.20 | 330 // TODO(sigmund): remove entirely after Dart 1.20 |
| 331 new OptionHandler( | 331 new OptionHandler( |
| 332 '--output-type=dart|--output-type=dart-multi|--output-type=js', | 332 '--output-type=dart|--output-type=dart-multi|--output-type=js', |
| 333 setOutputType), | 333 setOutputType), |
| 334 // TODO(efortuna): Remove this once kernel global inference is fully | 334 // TODO(efortuna): Remove this once kernel global inference is fully |
| 335 // implemented. | 335 // implemented. |
| 336 new OptionHandler(Flags.kernelGlobalInference, passThrough), | 336 new OptionHandler(Flags.kernelGlobalInference, passThrough), |
| 337 new OptionHandler(Flags.useKernel, passThrough), | 337 new OptionHandler(Flags.useKernelInSsa, passThrough), |
| 338 new OptionHandler(Flags.loadFromDill, setLoadFromDill), | 338 new OptionHandler(Flags.useKernel, setPreviewDart2), |
| 339 new OptionHandler(Flags.noFrequencyBasedMinification, passThrough), | 339 new OptionHandler(Flags.noFrequencyBasedMinification, passThrough), |
| 340 new OptionHandler(Flags.verbose, setVerbose), | 340 new OptionHandler(Flags.verbose, setVerbose), |
| 341 new OptionHandler(Flags.version, (_) => wantVersion = true), | 341 new OptionHandler(Flags.version, (_) => wantVersion = true), |
| 342 new OptionHandler('--library-root=.+', setLibraryRoot), | 342 new OptionHandler('--library-root=.+', setLibraryRoot), |
| 343 new OptionHandler('--out=.+|-o.*', setOutput, multipleArguments: true), | 343 new OptionHandler('--out=.+|-o.*', setOutput, multipleArguments: true), |
| 344 new OptionHandler(Flags.allowMockCompilation, passThrough), | 344 new OptionHandler(Flags.allowMockCompilation, passThrough), |
| 345 new OptionHandler(Flags.fastStartup, passThrough), | 345 new OptionHandler(Flags.fastStartup, passThrough), |
| 346 new OptionHandler(Flags.genericMethodSyntax, ignoreOption), | 346 new OptionHandler(Flags.genericMethodSyntax, ignoreOption), |
| 347 new OptionHandler(Flags.initializingFormalAccess, ignoreOption), | 347 new OptionHandler(Flags.initializingFormalAccess, ignoreOption), |
| 348 new OptionHandler('${Flags.minify}|-m', implyCompilation), | 348 new OptionHandler('${Flags.minify}|-m', implyCompilation), |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 } | 454 } |
| 455 if (showHints != null) { | 455 if (showHints != null) { |
| 456 diagnosticHandler.showHints = showHints; | 456 diagnosticHandler.showHints = showHints; |
| 457 } | 457 } |
| 458 if (enableColors != null) { | 458 if (enableColors != null) { |
| 459 diagnosticHandler.enableColors = enableColors; | 459 diagnosticHandler.enableColors = enableColors; |
| 460 } | 460 } |
| 461 for (String hint in hints) { | 461 for (String hint in hints) { |
| 462 diagnosticHandler.info(hint, api.Diagnostic.HINT); | 462 diagnosticHandler.info(hint, api.Diagnostic.HINT); |
| 463 } | 463 } |
| 464 if (loadFromDill) { | |
| 465 diagnosticHandler.autoReadFileUri = true; | |
| 466 } | |
| 467 | 464 |
| 468 if (wantHelp || wantVersion) { | 465 if (wantHelp || wantVersion) { |
| 469 helpAndExit(wantHelp, wantVersion, diagnosticHandler.verbose); | 466 helpAndExit(wantHelp, wantVersion, diagnosticHandler.verbose); |
| 470 } | 467 } |
| 471 | 468 |
| 472 if (hasDisallowUnsafeEval) { | 469 if (hasDisallowUnsafeEval) { |
| 473 String precompiledName = relativize( | 470 String precompiledName = relativize( |
| 474 currentDirectory, | 471 currentDirectory, |
| 475 RandomAccessFileOutputProvider.computePrecompiledUri(out), | 472 RandomAccessFileOutputProvider.computePrecompiledUri(out), |
| 476 Platform.isWindows); | 473 Platform.isWindows); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 } | 571 } |
| 575 } else if (explicitOutputArguments.isNotEmpty) { | 572 } else if (explicitOutputArguments.isNotEmpty) { |
| 576 String input = uriPathToNative(arguments[0]); | 573 String input = uriPathToNative(arguments[0]); |
| 577 String output = relativize(currentDirectory, out, Platform.isWindows); | 574 String output = relativize(currentDirectory, out, Platform.isWindows); |
| 578 print('Dart file ($input) compiled to JavaScript: $output'); | 575 print('Dart file ($input) compiled to JavaScript: $output'); |
| 579 } | 576 } |
| 580 return result; | 577 return result; |
| 581 } | 578 } |
| 582 | 579 |
| 583 Uri script = currentDirectory.resolve(arguments[0]); | 580 Uri script = currentDirectory.resolve(arguments[0]); |
| 581 if (useKernel && script.path.endsWith('.dill')) { |
| 582 diagnosticHandler.autoReadFileUri = true; |
| 583 } |
| 584 CompilerOptions compilerOptions = new CompilerOptions.parse( | 584 CompilerOptions compilerOptions = new CompilerOptions.parse( |
| 585 entryPoint: script, | 585 entryPoint: script, |
| 586 libraryRoot: libraryRoot, | 586 libraryRoot: libraryRoot, |
| 587 packageRoot: packageRoot, | 587 packageRoot: packageRoot, |
| 588 packageConfig: packageConfig, | 588 packageConfig: packageConfig, |
| 589 packagesDiscoveryProvider: findPackages, | 589 packagesDiscoveryProvider: findPackages, |
| 590 resolutionInputs: resolutionInputs, | 590 resolutionInputs: resolutionInputs, |
| 591 resolutionOutput: resolveOnly ? resolutionOutput : null, | 591 resolutionOutput: resolveOnly ? resolutionOutput : null, |
| 592 options: options, | 592 options: options, |
| 593 environment: environment); | 593 environment: environment); |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 @override | 1112 @override |
| 1113 void add(String event) { | 1113 void add(String event) { |
| 1114 sb.write(event); | 1114 sb.write(event); |
| 1115 } | 1115 } |
| 1116 | 1116 |
| 1117 @override | 1117 @override |
| 1118 void close() { | 1118 void close() { |
| 1119 // Do nothing. | 1119 // Do nothing. |
| 1120 } | 1120 } |
| 1121 } | 1121 } |
| OLD | NEW |