| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 fasta.compiler_command_line; | 5 library fasta.compiler_command_line; |
| 6 | 6 |
| 7 import 'dart:io' show exit; | 7 import 'dart:io' show exit; |
| 8 | 8 |
| 9 import 'command_line.dart' show CommandLine, argumentError; | 9 import 'command_line.dart' show CommandLine, argumentError; |
| 10 | 10 |
| 11 import 'compiler_context.dart' show CompilerContext; | 11 import 'compiler_context.dart' show CompilerContext; |
| 12 | 12 |
| 13 const Map<String, dynamic> optionSpecification = const <String, dynamic>{ | 13 const Map<String, dynamic> optionSpecification = const <String, dynamic>{ |
| 14 "--compile-sdk": Uri, | 14 "--compile-sdk": Uri, |
| 15 "--fatal": ",", | 15 "--fatal": ",", |
| 16 "--output": Uri, | 16 "--output": Uri, |
| 17 "-o": Uri, |
| 17 "--packages": Uri, | 18 "--packages": Uri, |
| 18 "--platform": Uri, | 19 "--platform": Uri, |
| 19 "-o": Uri, | 20 "--sdk": Uri, |
| 20 "--target": String, | 21 "--target": String, |
| 21 "-t": String, | 22 "-t": String, |
| 22 }; | 23 }; |
| 23 | 24 |
| 24 class CompilerCommandLine extends CommandLine { | 25 class CompilerCommandLine extends CommandLine { |
| 25 final String programName; | 26 final String programName; |
| 26 | 27 |
| 27 CompilerCommandLine(String programName, List<String> arguments) | 28 CompilerCommandLine(String programName, List<String> arguments) |
| 28 : programName = programName, | 29 : programName = programName, |
| 29 super(arguments, | 30 super(arguments, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 48 print(computeUsage(programName, verbose)); | 49 print(computeUsage(programName, verbose)); |
| 49 exit(0); | 50 exit(0); |
| 50 } | 51 } |
| 51 | 52 |
| 52 if (options.containsKey("-o") && options.containsKey("--output")) { | 53 if (options.containsKey("-o") && options.containsKey("--output")) { |
| 53 return argumentError(usage, "Can't specify both '-o' and '--output'."); | 54 return argumentError(usage, "Can't specify both '-o' and '--output'."); |
| 54 } | 55 } |
| 55 if (options.containsKey("-t") && options.containsKey("--target")) { | 56 if (options.containsKey("-t") && options.containsKey("--target")) { |
| 56 return argumentError(usage, "Can't specify both '-t' and '--target'."); | 57 return argumentError(usage, "Can't specify both '-t' and '--target'."); |
| 57 } | 58 } |
| 59 if (options.containsKey("--compile-sdk") && |
| 60 options.containsKey("--platform")) { |
| 61 return argumentError( |
| 62 usage, "Can't specify both '--compile-sdk' and '--platform'."); |
| 63 } |
| 58 if (programName == "compile_platform" && arguments.length != 3) { | 64 if (programName == "compile_platform" && arguments.length != 3) { |
| 59 return argumentError(usage, "Expected three arguments."); | 65 return argumentError(usage, "Expected three arguments."); |
| 60 } else if (arguments.isEmpty) { | 66 } else if (arguments.isEmpty) { |
| 61 return argumentError(usage, "No Dart file specified."); | 67 return argumentError(usage, "No Dart file specified."); |
| 62 } | 68 } |
| 63 } | 69 } |
| 64 | 70 |
| 65 Uri get output { | 71 Uri get output { |
| 66 return options["-o"] ?? options["--output"] ?? defaultOutput; | 72 return options["-o"] ?? options["--output"] ?? defaultOutput; |
| 67 } | 73 } |
| 68 | 74 |
| 69 Uri get defaultOutput => Uri.base.resolve("${arguments.first}.dill"); | 75 Uri get defaultOutput => Uri.base.resolve("${arguments.first}.dill"); |
| 70 | 76 |
| 71 Uri get platform { | 77 Uri get platform { |
| 72 return options.containsKey("--compile-sdk") | 78 return options.containsKey("--compile-sdk") |
| 73 ? null | 79 ? null |
| 74 : options["--platform"] ?? Uri.base.resolve("platform.dill"); | 80 : options["--platform"] ?? Uri.base.resolve("platform.dill"); |
| 75 } | 81 } |
| 76 | 82 |
| 77 Uri get packages => options["--packages"] ?? Uri.base.resolve(".packages"); | 83 Uri get packages => options["--packages"] ?? Uri.base.resolve(".packages"); |
| 78 | 84 |
| 79 Uri get sdk => options["--compile-sdk"]; | 85 Uri get sdk => options["--sdk"] ?? options["--compile-sdk"]; |
| 80 | 86 |
| 81 Set<String> get fatal { | 87 Set<String> get fatal { |
| 82 return new Set<String>.from(options["--fatal"] ?? <String>[]); | 88 return new Set<String>.from(options["--fatal"] ?? <String>[]); |
| 83 } | 89 } |
| 84 | 90 |
| 85 bool get errorsAreFatal => fatal.contains("errors"); | 91 bool get errorsAreFatal => fatal.contains("errors"); |
| 86 | 92 |
| 87 bool get warningsAreFatal => fatal.contains("warnings"); | 93 bool get warningsAreFatal => fatal.contains("warnings"); |
| 88 | 94 |
| 89 bool get nitsAreFatal => fatal.contains("nits"); | 95 bool get nitsAreFatal => fatal.contains("nits"); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 189 |
| 184 --dump-ir | 190 --dump-ir |
| 185 Print compiled libraries in Kernel source notation. | 191 Print compiled libraries in Kernel source notation. |
| 186 | 192 |
| 187 --exclude-source | 193 --exclude-source |
| 188 Do not include source code in the dill file. | 194 Do not include source code in the dill file. |
| 189 | 195 |
| 190 --compile-sdk=<patched_sdk> | 196 --compile-sdk=<patched_sdk> |
| 191 Compile the SDK from scratch instead of reading it from 'platform.dill'. | 197 Compile the SDK from scratch instead of reading it from 'platform.dill'. |
| 192 | 198 |
| 199 --sdk=<patched_sdk> |
| 200 Location of the SDK sources for use when compiling additional platform |
| 201 libraries. |
| 202 |
| 193 --fatal=errors | 203 --fatal=errors |
| 194 --fatal=warnings | 204 --fatal=warnings |
| 195 --fatal=nits | 205 --fatal=nits |
| 196 Makes messages of the given kinds fatal, that is, immediately stop the | 206 Makes messages of the given kinds fatal, that is, immediately stop the |
| 197 compiler with a non-zero exit-code. In --verbose mode, also display an | 207 compiler with a non-zero exit-code. In --verbose mode, also display an |
| 198 internal stack trace from the compiler. Multiple kinds can be separated by | 208 internal stack trace from the compiler. Multiple kinds can be separated by |
| 199 commas, for example, --fatal=errors,warnings. | 209 commas, for example, --fatal=errors,warnings. |
| 200 """; | 210 """; |
| OLD | NEW |