Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(983)

Side by Side Diff: pkg/front_end/lib/src/fasta/compiler_command_line.dart

Issue 2965393002: Use FastaMessage instead of String. Part 1. (Closed)
Patch Set: Add type variable to Code. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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, deprecated_argumentError; 9 import 'command_line.dart' show CommandLine, deprecated_argumentError;
10 10
11 import 'compiler_context.dart' show CompilerContext; 11 import 'compiler_context.dart' show CompilerContext;
12 12
13 import 'package:kernel/target/targets.dart' 13 import 'package:kernel/target/targets.dart'
14 show Target, getTarget, TargetFlags, targets; 14 show Target, getTarget, TargetFlags, targets;
15 15
16 import 'fasta_codes.dart'
17 show
18 Message,
19 messageFastaUsageLong,
20 messageFastaUsageShort,
21 templateUnspecified;
22
16 const Map<String, dynamic> optionSpecification = const <String, dynamic>{ 23 const Map<String, dynamic> optionSpecification = const <String, dynamic>{
17 "--compile-sdk": Uri, 24 "--compile-sdk": Uri,
18 "--fatal": ",", 25 "--fatal": ",",
19 "--output": Uri, 26 "--output": Uri,
20 "-o": Uri, 27 "-o": Uri,
21 "--packages": Uri, 28 "--packages": Uri,
22 "--platform": Uri, 29 "--platform": Uri,
23 "--sdk": Uri, 30 "--sdk": Uri,
24 "--target": String, 31 "--target": String,
25 "-t": String, 32 "-t": String,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 dynamic f(CompilerContext context)) { 128 dynamic f(CompilerContext context)) {
122 return CompilerContext.withGlobalOptions( 129 return CompilerContext.withGlobalOptions(
123 new CompilerCommandLine(programName, arguments), f); 130 new CompilerCommandLine(programName, arguments), f);
124 } 131 }
125 132
126 static CompilerCommandLine forRootContext() { 133 static CompilerCommandLine forRootContext() {
127 return new CompilerCommandLine("", [""]); 134 return new CompilerCommandLine("", [""]);
128 } 135 }
129 } 136 }
130 137
131 String computeUsage(String programName, bool verbose) { 138 Message computeUsage(String programName, bool verbose) {
132 String basicUsage = "Usage: $programName [options] dartfile\n"; 139 String basicUsage = "Usage: $programName [options] dartfile\n";
133 String summary; 140 String summary;
134 String options = (verbose ? allOptions : frequentOptions).trim(); 141 String options =
142 (verbose ? messageFastaUsageLong.message : messageFastaUsageShort.message)
143 .trim();
135 switch (programName) { 144 switch (programName) {
136 case "outline": 145 case "outline":
137 summary = 146 summary =
138 "Creates an outline of a Dart program in the Dill/Kernel IR format."; 147 "Creates an outline of a Dart program in the Dill/Kernel IR format.";
139 break; 148 break;
140 149
141 case "compile": 150 case "compile":
142 summary = "Compiles a Dart program to the Dill/Kernel IR format."; 151 summary = "Compiles a Dart program to the Dill/Kernel IR format.";
143 break; 152 break;
144 153
(...skipping 11 matching lines...) Expand all
156 basicUsage = "Usage: $programName [options] patched_sdk fullOutput " 165 basicUsage = "Usage: $programName [options] patched_sdk fullOutput "
157 "outlineOutput\n"; 166 "outlineOutput\n";
158 } 167 }
159 StringBuffer sb = new StringBuffer(basicUsage); 168 StringBuffer sb = new StringBuffer(basicUsage);
160 if (summary != null) { 169 if (summary != null) {
161 sb.writeln(); 170 sb.writeln();
162 sb.writeln(summary); 171 sb.writeln(summary);
163 sb.writeln(); 172 sb.writeln();
164 } 173 }
165 sb.write(options); 174 sb.write(options);
166 return "$sb"; 175 // TODO(ahe): Don't use [templateUnspecified].
176 return templateUnspecified.withArguments("$sb");
167 } 177 }
168
169 const String frequentOptions = """
170 Frequently used options:
171
172 -o <file> Generate the output into <file>.
173 -h Display this message (add -v for information about all options).
174 """;
175
176 const String allOptions = """
177 Supported options:
178
179 -o <file>, --output=<file>
180 Generate the output into <file>.
181
182 -h, /h, /?, --help
183 Display this message (add -v for information about all options).
184
185 -v, --verbose
186 Display verbose information.
187
188 --
189 Stop option parsing, the rest of the command line is assumed to be
190 file names or arguments to the Dart program.
191
192 --packages=<file>
193 Use package resolution configuration <file>, which should contain a mapping
194 of package names to paths.
195
196 --platform=<file>
197 Read the SDK platform from <file>, which should be in Dill/Kernel IR format
198 and contain the Dart SDK.
199
200 --target=none|vm|vmcc|vmreify|flutter
201 Specify the target configuration.
202
203 --verify
204 Check that the generated output is free of various problems. This is mostly
205 useful for developers of this compiler or Kernel transformations.
206
207 --dump-ir
208 Print compiled libraries in Kernel source notation.
209
210 --exclude-source
211 Do not include source code in the dill file.
212
213 --compile-sdk=<patched_sdk>
214 Compile the SDK from scratch instead of reading it from 'platform.dill'.
215
216 --sdk=<patched_sdk>
217 Location of the SDK sources for use when compiling additional platform
218 libraries.
219
220 --fatal=errors
221 --fatal=warnings
222 --fatal=nits
223 Makes messages of the given kinds fatal, that is, immediately stop the
224 compiler with a non-zero exit-code. In --verbose mode, also display an
225 internal stack trace from the compiler. Multiple kinds can be separated by
226 commas, for example, --fatal=errors,warnings.
227 """;
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/command_line.dart ('k') | pkg/front_end/lib/src/fasta/fasta_codes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698