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

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

Issue 2897683002: Move code for instantiating Invocation to Target. (Closed)
Patch Set: Rename vmTarget to targetInfo. Created 3 years, 7 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, 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 "-o": Uri, 19 "-o": Uri,
20 "--target": String,
21 "-t": String,
20 }; 22 };
21 23
22 class CompilerCommandLine extends CommandLine { 24 class CompilerCommandLine extends CommandLine {
23 final String programName; 25 final String programName;
24 26
25 CompilerCommandLine(String programName, List<String> arguments) 27 CompilerCommandLine(String programName, List<String> arguments)
26 : programName = programName, 28 : programName = programName,
27 super(arguments, 29 super(arguments,
28 specification: optionSpecification, 30 specification: optionSpecification,
29 usage: computeUsage(programName, false)); 31 usage: computeUsage(programName, false));
(...skipping 13 matching lines...) Expand all
43 45
44 void validate() { 46 void validate() {
45 if (help) { 47 if (help) {
46 print(computeUsage(programName, verbose)); 48 print(computeUsage(programName, verbose));
47 exit(0); 49 exit(0);
48 } 50 }
49 51
50 if (options.containsKey("-o") && options.containsKey("--output")) { 52 if (options.containsKey("-o") && options.containsKey("--output")) {
51 return argumentError(usage, "Can't specify both '-o' and '--output'."); 53 return argumentError(usage, "Can't specify both '-o' and '--output'.");
52 } 54 }
55 if (options.containsKey("-t") && options.containsKey("--target")) {
56 return argumentError(usage, "Can't specify both '-t' and '--target'.");
57 }
53 if (programName == "compile_platform" && arguments.length != 3) { 58 if (programName == "compile_platform" && arguments.length != 3) {
54 return argumentError(usage, "Expected three arguments."); 59 return argumentError(usage, "Expected three arguments.");
55 } else if (arguments.isEmpty) { 60 } else if (arguments.isEmpty) {
56 return argumentError(usage, "No Dart file specified."); 61 return argumentError(usage, "No Dart file specified.");
57 } 62 }
58 } 63 }
59 64
60 Uri get output { 65 Uri get output {
61 return options["-o"] ?? options["--output"] ?? defaultOutput; 66 return options["-o"] ?? options["--output"] ?? defaultOutput;
62 } 67 }
(...skipping 15 matching lines...) Expand all
78 } 83 }
79 84
80 bool get errorsAreFatal => fatal.contains("errors"); 85 bool get errorsAreFatal => fatal.contains("errors");
81 86
82 bool get warningsAreFatal => fatal.contains("warnings"); 87 bool get warningsAreFatal => fatal.contains("warnings");
83 88
84 bool get nitsAreFatal => fatal.contains("nits"); 89 bool get nitsAreFatal => fatal.contains("nits");
85 90
86 bool get strongMode => options.containsKey("--strong-mode"); 91 bool get strongMode => options.containsKey("--strong-mode");
87 92
93 String get target {
94 return options["-t"] ?? options["--target"] ?? "vm";
95 }
96
88 static dynamic withGlobalOptions(String programName, List<String> arguments, 97 static dynamic withGlobalOptions(String programName, List<String> arguments,
89 dynamic f(CompilerContext context)) { 98 dynamic f(CompilerContext context)) {
90 return CompilerContext.withGlobalOptions( 99 return CompilerContext.withGlobalOptions(
91 new CompilerCommandLine(programName, arguments), f); 100 new CompilerCommandLine(programName, arguments), f);
92 } 101 }
93 102
94 static CompilerCommandLine forRootContext() { 103 static CompilerCommandLine forRootContext() {
95 return new CompilerCommandLine("", [""]); 104 return new CompilerCommandLine("", [""]);
96 } 105 }
97 } 106 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 file names or arguments to the Dart program. 167 file names or arguments to the Dart program.
159 168
160 --packages=<file> 169 --packages=<file>
161 Use package resolution configuration <file>, which should contain a mapping 170 Use package resolution configuration <file>, which should contain a mapping
162 of package names to paths. 171 of package names to paths.
163 172
164 --platform=<file> 173 --platform=<file>
165 Read the SDK platform from <file>, which should be in Dill/Kernel IR format 174 Read the SDK platform from <file>, which should be in Dill/Kernel IR format
166 and contain the Dart SDK. 175 and contain the Dart SDK.
167 176
177 --target=none|vm|vmcc|vmreify|flutter
178 Specify the target configuration.
179
168 --verify 180 --verify
169 Check that the generated output is free of various problems. This is mostly 181 Check that the generated output is free of various problems. This is mostly
170 useful for developers of this compiler or Kernel transformations. 182 useful for developers of this compiler or Kernel transformations.
171 183
172 --dump-ir 184 --dump-ir
173 Print compiled libraries in Kernel source notation. 185 Print compiled libraries in Kernel source notation.
174 186
175 --exclude-source 187 --exclude-source
176 Do not include source code in the dill file. 188 Do not include source code in the dill file.
177 189
178 --compile-sdk=<patched_sdk> 190 --compile-sdk=<patched_sdk>
179 Compile the SDK from scratch instead of reading it from 'platform.dill'. 191 Compile the SDK from scratch instead of reading it from 'platform.dill'.
180 192
181 --fatal=errors 193 --fatal=errors
182 --fatal=warnings 194 --fatal=warnings
183 --fatal=nits 195 --fatal=nits
184 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
185 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
186 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
187 commas, for example, --fatal=errors,warnings. 199 commas, for example, --fatal=errors,warnings.
188 """; 200 """;
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/compile_platform.dart ('k') | pkg/front_end/lib/src/fasta/dill/dill_target.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698