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 "--packages": Uri, | 17 "--packages": Uri, |
18 "--platform": Uri, | 18 "--platform": Uri, |
19 "--target": String, | |
19 "-o": Uri, | 20 "-o": Uri, |
20 }; | 21 }; |
21 | 22 |
22 class CompilerCommandLine extends CommandLine { | 23 class CompilerCommandLine extends CommandLine { |
23 final String programName; | 24 final String programName; |
24 | 25 |
25 CompilerCommandLine(String programName, List<String> arguments) | 26 CompilerCommandLine(String programName, List<String> arguments) |
26 : programName = programName, | 27 : programName = programName, |
27 super(arguments, | 28 super(arguments, |
28 specification: optionSpecification, | 29 specification: optionSpecification, |
(...skipping 19 matching lines...) Expand all Loading... | |
48 } | 49 } |
49 | 50 |
50 if (options.containsKey("-o") && options.containsKey("--output")) { | 51 if (options.containsKey("-o") && options.containsKey("--output")) { |
51 return argumentError(usage, "Can't specify both '-o' and '--output'."); | 52 return argumentError(usage, "Can't specify both '-o' and '--output'."); |
52 } | 53 } |
53 if (programName == "compile_platform" && arguments.length != 2) { | 54 if (programName == "compile_platform" && arguments.length != 2) { |
54 return argumentError(usage, "Expected two arguments."); | 55 return argumentError(usage, "Expected two arguments."); |
55 } else if (arguments.isEmpty) { | 56 } else if (arguments.isEmpty) { |
56 return argumentError(usage, "No Dart file specified."); | 57 return argumentError(usage, "No Dart file specified."); |
57 } | 58 } |
59 if (!targetDart2js && !targetVm) { | |
60 return argumentError(usage, "Invalid target"); | |
ahe
2017/04/27 13:34:34
"Unknown target: '${options["--target"]}'."
Siggi Cherem (dart-lang)
2017/04/28 21:37:20
n/a anymore (flag is gone)
| |
61 } | |
58 } | 62 } |
59 | 63 |
60 Uri get output { | 64 Uri get output { |
61 return options["-o"] ?? options["--output"] ?? defaultOutput; | 65 return options["-o"] ?? options["--output"] ?? defaultOutput; |
62 } | 66 } |
63 | 67 |
64 Uri get defaultOutput => Uri.base.resolve("${arguments.first}.dill"); | 68 Uri get defaultOutput => Uri.base.resolve("${arguments.first}.dill"); |
65 | 69 |
66 Uri get platform { | 70 Uri get platform { |
67 return options.containsKey("--compile-sdk") | 71 return options.containsKey("--compile-sdk") |
68 ? null | 72 ? null |
69 : options["--platform"] ?? Uri.base.resolve("platform.dill"); | 73 : options["--platform"] ?? Uri.base.resolve("platform.dill"); |
70 } | 74 } |
71 | 75 |
72 Uri get packages => options["--packages"] ?? Uri.base.resolve(".packages"); | 76 Uri get packages => options["--packages"] ?? Uri.base.resolve(".packages"); |
73 | 77 |
74 Uri get sdk => options["--compile-sdk"]; | 78 Uri get sdk => options["--compile-sdk"]; |
75 | 79 |
80 bool get targetDart2js => options["--target"] == 'dart2js'; | |
81 bool get targetVm => (options["--target"] ?? 'vm') == 'vm'; | |
82 | |
76 Set<String> get fatal { | 83 Set<String> get fatal { |
77 return new Set<String>.from(options["--fatal"] ?? <String>[]); | 84 return new Set<String>.from(options["--fatal"] ?? <String>[]); |
78 } | 85 } |
79 | 86 |
80 bool get errorsAreFatal => fatal.contains("errors"); | 87 bool get errorsAreFatal => fatal.contains("errors"); |
81 | 88 |
82 bool get warningsAreFatal => fatal.contains("warnings"); | 89 bool get warningsAreFatal => fatal.contains("warnings"); |
83 | 90 |
84 bool get nitsAreFatal => fatal.contains("nits"); | 91 bool get nitsAreFatal => fatal.contains("nits"); |
85 | 92 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 | 177 |
171 --dump-ir | 178 --dump-ir |
172 Print compiled libraries in Kernel source notation. | 179 Print compiled libraries in Kernel source notation. |
173 | 180 |
174 --exclude-source | 181 --exclude-source |
175 Do not include source code in the dill file. | 182 Do not include source code in the dill file. |
176 | 183 |
177 --compile-sdk=<patched_sdk> | 184 --compile-sdk=<patched_sdk> |
178 Compile the SDK from scratch instead of reading it from 'platform.dill'. | 185 Compile the SDK from scratch instead of reading it from 'platform.dill'. |
179 | 186 |
187 --target=vm | |
188 --target=dart2js | |
189 Compile with the intention to pass the output to the given target. This will | |
190 affect which patch files are used for compiling the SDK and what | |
191 transformations will be done in the Kernel representation. | |
192 | |
180 --fatal=errors | 193 --fatal=errors |
181 --fatal=warnings | 194 --fatal=warnings |
182 --fatal=nits | 195 --fatal=nits |
183 Makes messages of the given kinds fatal, that is, immediately stop the | 196 Makes messages of the given kinds fatal, that is, immediately stop the |
184 compiler with a non-zero exit-code. In --verbose mode, also display an | 197 compiler with a non-zero exit-code. In --verbose mode, also display an |
185 internal stack trace from the compiler. Multiple kinds can be separated by | 198 internal stack trace from the compiler. Multiple kinds can be separated by |
186 commas, for example, --fatal=errors,warnings. | 199 commas, for example, --fatal=errors,warnings. |
187 """; | 200 """; |
OLD | NEW |