OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 /// Command line tool to run the checker on a Dart program. | 6 /// Runs dev_compiler's checker, and optionally the code generator. |
| 7 /// Also can run a server for local development. |
7 library dev_compiler.bin.devc; | 8 library dev_compiler.bin.devc; |
8 | 9 |
9 import 'dart:io'; | 10 import 'dart:io'; |
10 | 11 |
11 import 'package:dev_compiler/devc.dart'; | 12 import 'package:dev_compiler/devc.dart'; |
12 import 'package:dev_compiler/src/options.dart'; | 13 import 'package:dev_compiler/src/options.dart'; |
13 | 14 |
14 void _showUsageAndExit() { | 15 void _showUsageAndExit() { |
15 print('usage: dartdevc [<options>] <file.dart>\n'); | 16 print('usage: dartdevc [<options>] <file.dart>...\n'); |
16 print('<file.dart> is a single Dart file to process.\n'); | 17 print('<file.dart> is one or more Dart files to process.\n'); |
17 print('<options> include:\n'); | 18 print('<options> include:\n'); |
18 print(argParser.usage); | 19 print(argParser.usage); |
19 exit(1); | 20 exit(1); |
20 } | 21 } |
21 | 22 |
22 void main(List<String> args) { | 23 void main(List<String> args) { |
23 var options = parseOptions(args); | 24 var options = parseOptions(args); |
24 if (options.help) _showUsageAndExit(); | 25 if (options.help) _showUsageAndExit(); |
25 | 26 |
26 var srcOpts = options.sourceOptions; | 27 var srcOpts = options.sourceOptions; |
27 if (!srcOpts.useMockSdk && srcOpts.dartSdkPath == null) { | 28 if (!srcOpts.useMockSdk && srcOpts.dartSdkPath == null) { |
28 print('Could not automatically find dart sdk path.'); | 29 print('Could not automatically find dart sdk path.'); |
29 print('Please pass in explicitly: --dart-sdk <path>'); | 30 print('Please pass in explicitly: --dart-sdk <path>'); |
30 exit(1); | 31 exit(1); |
31 } | 32 } |
32 | 33 |
33 if (srcOpts.entryPointFile == null) { | 34 if (options.inputs.length == 0) { |
34 print('Expected filename.'); | 35 print('Expected filename.'); |
35 _showUsageAndExit(); | 36 _showUsageAndExit(); |
36 } | 37 } |
37 | 38 |
38 setupLogger(options.logLevel, print); | 39 setupLogger(options.logLevel, print); |
39 | 40 |
40 if (options.serverMode) { | 41 if (options.serverMode) { |
41 new CompilerServer(options).start(); | 42 new DevServer(options).start(); |
42 } else { | 43 } else { |
43 var result = new Compiler(options).run(); | 44 var context = createAnalysisContextWithSources( |
44 exit(result.failure ? 1 : 0); | 45 options.strongOptions, options.sourceOptions); |
| 46 var reporter = createErrorReporter(context, options); |
| 47 var success = new BatchCompiler(context, options, reporter: reporter).run(); |
| 48 exit(success ? 0 : 1); |
45 } | 49 } |
46 } | 50 } |
OLD | NEW |