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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/command.dart

Issue 2598593003: support --options flag and other analysis options flags in DDC (Closed)
Patch Set: merge Created 3 years, 11 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 import 'dart:io'; 5 import 'dart:io';
6 import 'package:analyzer/src/command_line/arguments.dart' 6 import 'package:analyzer/src/command_line/arguments.dart'
7 show 7 show
8 defineAnalysisArguments, 8 defineAnalysisArguments,
9 filterUnknownArguments, 9 filterUnknownArguments,
10 ignoreUnrecognizedFlagsFlag; 10 ignoreUnrecognizedFlagsFlag;
(...skipping 14 matching lines...) Expand all
25 /// 25 ///
26 /// This handles argument parsing, usage, error handling. 26 /// This handles argument parsing, usage, error handling.
27 /// See bin/dartdevc.dart for the actual entry point, which includes Bazel 27 /// See bin/dartdevc.dart for the actual entry point, which includes Bazel
28 /// worker support. 28 /// worker support.
29 int compile(List<String> args, {void printFn(Object obj)}) { 29 int compile(List<String> args, {void printFn(Object obj)}) {
30 printFn ??= print; 30 printFn ??= print;
31 31
32 ArgResults argResults; 32 ArgResults argResults;
33 AnalyzerOptions analyzerOptions; 33 AnalyzerOptions analyzerOptions;
34 try { 34 try {
35 var parser = _argParser(); 35 var parser = ddcArgParser();
36 if (args.contains('--$ignoreUnrecognizedFlagsFlag')) { 36 if (args.contains('--$ignoreUnrecognizedFlagsFlag')) {
37 args = filterUnknownArguments(args, parser); 37 args = filterUnknownArguments(args, parser);
38 } 38 }
39 argResults = parser.parse(args); 39 argResults = parser.parse(args);
40 analyzerOptions = new AnalyzerOptions.fromArguments(argResults); 40 analyzerOptions = new AnalyzerOptions.fromArguments(argResults);
41 } on FormatException catch (error) { 41 } on FormatException catch (error) {
42 printFn('$error\n\n$_usageMessage'); 42 printFn('$error\n\n$_usageMessage');
43 return 64; 43 return 64;
44 } 44 }
45 45
(...skipping 30 matching lines...) Expand all
76 dartdevc arguments: ${args.join(' ')} 76 dartdevc arguments: ${args.join(' ')}
77 dart --version: ${Platform.version} 77 dart --version: ${Platform.version}
78 ``` 78 ```
79 $error 79 $error
80 $stackTrace 80 $stackTrace
81 ```'''); 81 ```''');
82 return 70; 82 return 70;
83 } 83 }
84 } 84 }
85 85
86 ArgParser _argParser({bool hide: true}) { 86 ArgParser ddcArgParser({bool hide: true}) {
87 var argParser = new ArgParser(allowTrailingOptions: true) 87 var argParser = new ArgParser(allowTrailingOptions: true)
88 ..addFlag('help', 88 ..addFlag('help',
89 abbr: 'h', 89 abbr: 'h',
90 help: 'Display this message.\n' 90 help: 'Display this message.\n'
91 'Add --verbose to show hidden options.', 91 'Add --verbose to show hidden options.',
92 negatable: false) 92 negatable: false)
93 ..addFlag('verbose', abbr: 'v', help: 'Verbose output.') 93 ..addFlag('verbose', abbr: 'v', help: 'Verbose output.')
94 ..addFlag(ignoreUnrecognizedFlagsFlag, 94 ..addFlag(ignoreUnrecognizedFlagsFlag,
95 help: 'Ignore unrecognized command line flags.', 95 help: 'Ignore unrecognized command line flags.',
96 defaultsTo: false, 96 defaultsTo: false,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 _usageException( 219 _usageException(
220 'Imported file "${source.uri}" was not found as a summary or source ' 220 'Imported file "${source.uri}" was not found as a summary or source '
221 'file. Please pass in either the summary or the source file ' 221 'file. Please pass in either the summary or the source file '
222 'for this import.'); 222 'for this import.');
223 return null; // unreachable 223 return null; // unreachable
224 } 224 }
225 225
226 String get _usageMessage => 226 String get _usageMessage =>
227 'Dart Development Compiler compiles Dart into a JavaScript module.' 227 'Dart Development Compiler compiles Dart into a JavaScript module.'
228 '\n\n${_argParser(hide: !_verbose).usage}'; 228 '\n\n${ddcArgParser(hide: !_verbose).usage}';
229 229
230 void _usageException(String message) { 230 void _usageException(String message) {
231 throw new UsageException(message, _usageMessage); 231 throw new UsageException(message, _usageMessage);
232 } 232 }
233 233
234 /// Thrown when the input source code has errors. 234 /// Thrown when the input source code has errors.
235 class CompileErrorException implements Exception { 235 class CompileErrorException implements Exception {
236 toString() => '\nPlease fix all errors before compiling (warnings are okay).'; 236 toString() => '\nPlease fix all errors before compiling (warnings are okay).';
237 } 237 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/lib/src/analyzer/context.dart ('k') | pkg/dev_compiler/lib/src/compiler/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698