| 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 'package:kernel/target/targets.dart' |
| 10 show Target, getTarget, TargetFlags, targets; |
| 11 |
| 9 import 'command_line.dart' show CommandLine, deprecated_argumentError; | 12 import 'command_line.dart' show CommandLine, deprecated_argumentError; |
| 10 | 13 |
| 11 import 'compiler_context.dart' show CompilerContext; | 14 import 'compiler_context.dart' show CompilerContext; |
| 12 | 15 |
| 13 import 'package:kernel/target/targets.dart' | 16 import 'command_line_reporting.dart' as command_line_reporting; |
| 14 show Target, getTarget, TargetFlags, targets; | |
| 15 | 17 |
| 16 import 'fasta_codes.dart' | 18 import 'fasta_codes.dart' |
| 17 show | 19 show |
| 20 LocatedMessage, |
| 18 Message, | 21 Message, |
| 19 messageFastaUsageLong, | 22 messageFastaUsageLong, |
| 20 messageFastaUsageShort, | 23 messageFastaUsageShort, |
| 21 templateUnspecified; | 24 templateUnspecified; |
| 22 | 25 |
| 26 import 'severity.dart' show Severity; |
| 27 |
| 23 const Map<String, dynamic> optionSpecification = const <String, dynamic>{ | 28 const Map<String, dynamic> optionSpecification = const <String, dynamic>{ |
| 24 "--compile-sdk": Uri, | 29 "--compile-sdk": Uri, |
| 25 "--fatal": ",", | 30 "--fatal": ",", |
| 26 "--output": Uri, | 31 "--output": Uri, |
| 27 "-o": Uri, | 32 "-o": Uri, |
| 28 "--packages": Uri, | 33 "--packages": Uri, |
| 29 "--platform": Uri, | 34 "--platform": Uri, |
| 30 "--sdk": Uri, | 35 "--sdk": Uri, |
| 31 "--target": String, | 36 "--target": String, |
| 32 "-t": String, | 37 "-t": String, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 bool get nitsAreFatal => fatal.contains("nits"); | 126 bool get nitsAreFatal => fatal.contains("nits"); |
| 122 | 127 |
| 123 bool get strongMode => options.containsKey("--strong-mode"); | 128 bool get strongMode => options.containsKey("--strong-mode"); |
| 124 | 129 |
| 125 String get targetName { | 130 String get targetName { |
| 126 return options["-t"] ?? options["--target"] ?? "vm_fasta"; | 131 return options["-t"] ?? options["--target"] ?? "vm_fasta"; |
| 127 } | 132 } |
| 128 | 133 |
| 129 Target get target => options["target"]; | 134 Target get target => options["target"]; |
| 130 | 135 |
| 136 void Function(LocatedMessage, Severity) get report { |
| 137 return options["report"] ?? command_line_reporting.report; |
| 138 } |
| 139 |
| 140 void Function(Message, Severity) get reportWithoutLocation { |
| 141 return options["reportWithoutLocation"] ?? |
| 142 command_line_reporting.reportWithoutLocation; |
| 143 } |
| 144 |
| 145 String Function(LocatedMessage, Severity) get format { |
| 146 return options["format"] ?? command_line_reporting.format; |
| 147 } |
| 148 |
| 149 String Function(Message, Severity) get formatWithoutLocation { |
| 150 return options["formatWithoutLocation"] ?? |
| 151 command_line_reporting.formatWithoutLocation; |
| 152 } |
| 153 |
| 131 static dynamic withGlobalOptions(String programName, List<String> arguments, | 154 static dynamic withGlobalOptions(String programName, List<String> arguments, |
| 132 dynamic f(CompilerContext context)) { | 155 dynamic f(CompilerContext context)) { |
| 133 return CompilerContext.withGlobalOptions( | 156 return CompilerContext.withGlobalOptions( |
| 134 new CompilerCommandLine(programName, arguments), f); | 157 new CompilerCommandLine(programName, arguments), f); |
| 135 } | 158 } |
| 136 | 159 |
| 137 static CompilerCommandLine forRootContext() { | 160 static CompilerCommandLine forRootContext() { |
| 138 return new CompilerCommandLine("", [""]); | 161 return new CompilerCommandLine("", [""]); |
| 139 } | 162 } |
| 140 } | 163 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 StringBuffer sb = new StringBuffer(basicUsage); | 195 StringBuffer sb = new StringBuffer(basicUsage); |
| 173 if (summary != null) { | 196 if (summary != null) { |
| 174 sb.writeln(); | 197 sb.writeln(); |
| 175 sb.writeln(summary); | 198 sb.writeln(summary); |
| 176 sb.writeln(); | 199 sb.writeln(); |
| 177 } | 200 } |
| 178 sb.write(options); | 201 sb.write(options); |
| 179 // TODO(ahe): Don't use [templateUnspecified]. | 202 // TODO(ahe): Don't use [templateUnspecified]. |
| 180 return templateUnspecified.withArguments("$sb"); | 203 return templateUnspecified.withArguments("$sb"); |
| 181 } | 204 } |
| OLD | NEW |