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

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

Issue 2932513003: Add getTarget method to CompilerCommandLine (Closed)
Patch Set: Adjust CL to the changes in "master" 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'
14 show Target, getTarget, TargetFlags, targets;
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 };
(...skipping 30 matching lines...) Expand all
53 return argumentError(usage, "Can't specify both '-o' and '--output'."); 56 return argumentError(usage, "Can't specify both '-o' and '--output'.");
54 } 57 }
55 if (options.containsKey("-t") && options.containsKey("--target")) { 58 if (options.containsKey("-t") && options.containsKey("--target")) {
56 return argumentError(usage, "Can't specify both '-t' and '--target'."); 59 return argumentError(usage, "Can't specify both '-t' and '--target'.");
57 } 60 }
58 if (programName == "compile_platform" && arguments.length != 3) { 61 if (programName == "compile_platform" && arguments.length != 3) {
59 return argumentError(usage, "Expected three arguments."); 62 return argumentError(usage, "Expected three arguments.");
60 } else if (arguments.isEmpty) { 63 } else if (arguments.isEmpty) {
61 return argumentError(usage, "No Dart file specified."); 64 return argumentError(usage, "No Dart file specified.");
62 } 65 }
66
67 Target target =
68 getTarget(targetName, new TargetFlags(strongMode: strongMode));
69 if (target == null) {
70 return argumentError(
71 usage,
72 "Target '${targetName}' not recognized. "
73 "Valid targets are:\n ${targets.keys.join("\n ")}");
74 }
75 options["target"] = target;
63 } 76 }
64 77
65 Uri get output { 78 Uri get output {
66 return options["-o"] ?? options["--output"] ?? defaultOutput; 79 return options["-o"] ?? options["--output"] ?? defaultOutput;
67 } 80 }
68 81
69 Uri get defaultOutput => Uri.base.resolve("${arguments.first}.dill"); 82 Uri get defaultOutput => Uri.base.resolve("${arguments.first}.dill");
70 83
71 Uri get platform { 84 Uri get platform {
72 return options.containsKey("--compile-sdk") 85 return options.containsKey("--compile-sdk")
(...skipping 10 matching lines...) Expand all
83 } 96 }
84 97
85 bool get errorsAreFatal => fatal.contains("errors"); 98 bool get errorsAreFatal => fatal.contains("errors");
86 99
87 bool get warningsAreFatal => fatal.contains("warnings"); 100 bool get warningsAreFatal => fatal.contains("warnings");
88 101
89 bool get nitsAreFatal => fatal.contains("nits"); 102 bool get nitsAreFatal => fatal.contains("nits");
90 103
91 bool get strongMode => options.containsKey("--strong-mode"); 104 bool get strongMode => options.containsKey("--strong-mode");
92 105
93 String get target { 106 String get targetName {
94 return options["-t"] ?? options["--target"] ?? "vm_fasta"; 107 return options["-t"] ?? options["--target"] ?? "vm_fasta";
95 } 108 }
96 109
110 Target get target => options["target"];
111
97 static dynamic withGlobalOptions(String programName, List<String> arguments, 112 static dynamic withGlobalOptions(String programName, List<String> arguments,
98 dynamic f(CompilerContext context)) { 113 dynamic f(CompilerContext context)) {
99 return CompilerContext.withGlobalOptions( 114 return CompilerContext.withGlobalOptions(
100 new CompilerCommandLine(programName, arguments), f); 115 new CompilerCommandLine(programName, arguments), f);
101 } 116 }
102 117
103 static CompilerCommandLine forRootContext() { 118 static CompilerCommandLine forRootContext() {
104 return new CompilerCommandLine("", [""]); 119 return new CompilerCommandLine("", [""]);
105 } 120 }
106 } 121 }
(...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'. 206 Compile the SDK from scratch instead of reading it from 'platform.dill'.
192 207
193 --fatal=errors 208 --fatal=errors
194 --fatal=warnings 209 --fatal=warnings
195 --fatal=nits 210 --fatal=nits
196 Makes messages of the given kinds fatal, that is, immediately stop the 211 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 212 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 213 internal stack trace from the compiler. Multiple kinds can be separated by
199 commas, for example, --fatal=errors,warnings. 214 commas, for example, --fatal=errors,warnings.
200 """; 215 """;
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