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 /// Command line tool to run the checker on a Dart program. |
7 library ddc.bin.checker; | 7 library ddc.bin.checker; |
8 | 8 |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 | 10 |
11 import 'package:dev_compiler/devc.dart'; | 11 import 'package:dev_compiler/devc.dart'; |
12 import 'package:dev_compiler/src/checker/dart_sdk.dart' show mockSdkSources; | |
13 import 'package:dev_compiler/src/checker/resolver.dart' show TypeResolver; | |
14 import 'package:dev_compiler/src/options.dart'; | 12 import 'package:dev_compiler/src/options.dart'; |
15 | 13 |
16 void _showUsageAndExit() { | 14 void _showUsageAndExit() { |
17 print('usage: dartdevc [<options>] <file.dart>\n'); | 15 print('usage: dartdevc [<options>] <file.dart>\n'); |
18 print('<file.dart> is a single Dart file to process.\n'); | 16 print('<file.dart> is a single Dart file to process.\n'); |
19 print('<options> include:\n'); | 17 print('<options> include:\n'); |
20 print(argParser.usage); | 18 print(argParser.usage); |
21 exit(1); | 19 exit(1); |
22 } | 20 } |
23 | 21 |
24 void main(List<String> args) { | 22 void main(List<String> args) { |
25 var options = parseOptions(args); | 23 var options = parseOptions(args); |
26 if (options.help) _showUsageAndExit(); | 24 if (options.help) _showUsageAndExit(); |
27 | 25 |
28 if (!options.useMockSdk && options.dartSdkPath == null) { | 26 if (!options.useMockSdk && options.dartSdkPath == null) { |
29 print('Could not automatically find dart sdk path.'); | 27 print('Could not automatically find dart sdk path.'); |
30 print('Please pass in explicitly: --dart-sdk <path>'); | 28 print('Please pass in explicitly: --dart-sdk <path>'); |
31 exit(1); | 29 exit(1); |
32 } | 30 } |
33 | 31 |
34 if (options.entryPointFile == null) { | 32 if (options.entryPointFile == null) { |
35 print('Expected filename.'); | 33 print('Expected filename.'); |
36 _showUsageAndExit(); | 34 _showUsageAndExit(); |
37 } | 35 } |
38 | 36 |
39 if (!options.dumpInfo) setupLogger(options.logLevel, print); | 37 if (!options.dumpInfo) setupLogger(options.logLevel, print); |
40 | 38 |
41 var typeResolver = options.useMockSdk | 39 if (options.serverMode) { |
42 ? new TypeResolver.fromMock(mockSdkSources, options) | 40 new CompilerServer(options).start(); |
43 : new TypeResolver.fromDir(options.dartSdkPath, options); | 41 } else { |
44 var result = compile(options.entryPointFile, typeResolver, options); | 42 var result = new Compiler(options).run(); |
45 exit(result.failure ? 1 : 0); | 43 exit(result.failure ? 1 : 0); |
| 44 } |
46 } | 45 } |
OLD | NEW |