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

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

Issue 2932513003: Add getTarget method to CompilerCommandLine (Closed)
Patch Set: Created 3 years, 6 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 import 'package:kernel/target/targets.dart' as backend_targets
14 show Target, getTarget, TargetFlags;
15
13 const Map<String, dynamic> optionSpecification = const <String, dynamic>{ 16 const Map<String, dynamic> optionSpecification = const <String, dynamic>{
14 "--compile-sdk": Uri, 17 "--compile-sdk": Uri,
15 "--fatal": ",", 18 "--fatal": ",",
16 "--output": Uri, 19 "--output": Uri,
17 "--packages": Uri, 20 "--packages": Uri,
18 "--platform": Uri, 21 "--platform": Uri,
19 "-o": Uri, 22 "-o": Uri,
20 "--target": String, 23 "--target": String,
21 "-t": String, 24 "-t": String,
22 }; 25 };
23 26
24 class CompilerCommandLine extends CommandLine { 27 class CompilerCommandLine extends CommandLine {
25 final String programName; 28 final String programName;
29 backend_targets.Target cachedTarget;
26 30
27 CompilerCommandLine(String programName, List<String> arguments) 31 CompilerCommandLine(String programName, List<String> arguments)
28 : programName = programName, 32 : programName = programName,
29 super(arguments, 33 super(arguments,
30 specification: optionSpecification, 34 specification: optionSpecification,
31 usage: computeUsage(programName, false)); 35 usage: computeUsage(programName, false));
32 36
33 bool get verify => options.containsKey("--verify"); 37 bool get verify => options.containsKey("--verify");
34 38
35 bool get dumpIr => options.containsKey("--dump-ir"); 39 bool get dumpIr => options.containsKey("--dump-ir");
(...skipping 16 matching lines...) Expand all
52 if (options.containsKey("-o") && options.containsKey("--output")) { 56 if (options.containsKey("-o") && options.containsKey("--output")) {
53 return argumentError(usage, "Can't specify both '-o' and '--output'."); 57 return argumentError(usage, "Can't specify both '-o' and '--output'.");
54 } 58 }
55 if (options.containsKey("-t") && options.containsKey("--target")) { 59 if (options.containsKey("-t") && options.containsKey("--target")) {
56 return argumentError(usage, "Can't specify both '-t' and '--target'."); 60 return argumentError(usage, "Can't specify both '-t' and '--target'.");
57 } 61 }
58 if (programName == "compile_platform" && arguments.length != 3) { 62 if (programName == "compile_platform" && arguments.length != 3) {
59 return argumentError(usage, "Expected three arguments."); 63 return argumentError(usage, "Expected three arguments.");
60 } else if (arguments.isEmpty) { 64 } else if (arguments.isEmpty) {
61 return argumentError(usage, "No Dart file specified."); 65 return argumentError(usage, "No Dart file specified.");
62 } 66 }
ahe 2017/06/08 14:49:37 Suggestion: backend_targets.Target target = backe
Dmitry Stefantsov 2017/06/09 08:24:40 Thanks for the suggestion! I agree. This way we ma
63 } 67 }
64 68
65 Uri get output { 69 Uri get output {
66 return options["-o"] ?? options["--output"] ?? defaultOutput; 70 return options["-o"] ?? options["--output"] ?? defaultOutput;
67 } 71 }
68 72
69 Uri get defaultOutput => Uri.base.resolve("${arguments.first}.dill"); 73 Uri get defaultOutput => Uri.base.resolve("${arguments.first}.dill");
70 74
71 Uri get platform { 75 Uri get platform {
72 return options.containsKey("--compile-sdk") 76 return options.containsKey("--compile-sdk")
(...skipping 10 matching lines...) Expand all
83 } 87 }
84 88
85 bool get errorsAreFatal => fatal.contains("errors"); 89 bool get errorsAreFatal => fatal.contains("errors");
86 90
87 bool get warningsAreFatal => fatal.contains("warnings"); 91 bool get warningsAreFatal => fatal.contains("warnings");
88 92
89 bool get nitsAreFatal => fatal.contains("nits"); 93 bool get nitsAreFatal => fatal.contains("nits");
90 94
91 bool get strongMode => options.containsKey("--strong-mode"); 95 bool get strongMode => options.containsKey("--strong-mode");
92 96
93 String get target { 97 String get target {
ahe 2017/06/08 14:49:37 Rename this to targetName.
Dmitry Stefantsov 2017/06/09 08:24:40 Done.
94 return options["-t"] ?? options["--target"] ?? "vm_fasta"; 98 return options["-t"] ?? options["--target"] ?? "vm_fasta";
95 } 99 }
96 100
101 backend_targets.Target getTarget() {
ahe 2017/06/08 14:49:37 Change this to: backend_targets.Target get target
Dmitry Stefantsov 2017/06/09 08:24:40 Done.
102 if (cachedTarget != null) {
103 return cachedTarget;
104 }
105 return cachedTarget = backend_targets.getTarget(
ahe 2017/06/08 14:49:37 Use ??=
Dmitry Stefantsov 2017/06/09 08:24:40 Thanks for the suggestion! It looks way better tha
106 target, new backend_targets.TargetFlags(strongMode: strongMode));
107 }
108
97 static dynamic withGlobalOptions(String programName, List<String> arguments, 109 static dynamic withGlobalOptions(String programName, List<String> arguments,
98 dynamic f(CompilerContext context)) { 110 dynamic f(CompilerContext context)) {
99 return CompilerContext.withGlobalOptions( 111 return CompilerContext.withGlobalOptions(
100 new CompilerCommandLine(programName, arguments), f); 112 new CompilerCommandLine(programName, arguments), f);
101 } 113 }
102 114
103 static CompilerCommandLine forRootContext() { 115 static CompilerCommandLine forRootContext() {
104 return new CompilerCommandLine("", [""]); 116 return new CompilerCommandLine("", [""]);
105 } 117 }
106 } 118 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 Compile the SDK from scratch instead of reading it from 'platform.dill'. 203 Compile the SDK from scratch instead of reading it from 'platform.dill'.
192 204
193 --fatal=errors 205 --fatal=errors
194 --fatal=warnings 206 --fatal=warnings
195 --fatal=nits 207 --fatal=nits
196 Makes messages of the given kinds fatal, that is, immediately stop the 208 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 209 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 210 internal stack trace from the compiler. Multiple kinds can be separated by
199 commas, for example, --fatal=errors,warnings. 211 commas, for example, --fatal=errors,warnings.
200 """; 212 """;
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/compile_platform.dart ('k') | pkg/front_end/lib/src/fasta/fasta.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698