OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2016, 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 @JS() | 6 @JS() |
7 library dev_compiler.web.main; | 7 library dev_compiler.web.main; |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 | 10 |
11 import 'package:args/command_runner.dart'; | 11 import 'package:args/command_runner.dart'; |
12 import 'package:js/js.dart'; | 12 import 'package:js/js.dart'; |
13 | 13 |
14 import 'web_command.dart'; | 14 import 'web_command.dart'; |
15 | 15 |
16 @JS(r'$setUpDartDevCompilerInBrowser') | 16 @JS(r'$setUpDartDevCompilerInBrowser') |
17 external set setUpCompilerInBrowser(Function function); | 17 external set setUpCompilerInBrowser(Function function); |
18 | 18 |
19 Future<Function> _setUpCompilerInBrowser; | 19 Future<Function> _setUpCompilerInBrowser; |
20 main() { | 20 main() { |
21 var args = ['compile', '--repl-compile']; | 21 var args = ['compile', '--repl-compile']; |
22 | 22 |
23 // Avoid race condition when users try to call $setUpDartDevCompilerInBrowser | 23 // Avoid race condition when users try to call $setUpDartDevCompilerInBrowser |
24 // before it is ready by installing the method immediately and making the body | 24 // before it is ready by installing the method immediately and making the body |
25 // of the method async. | 25 // of the method async. |
26 setUpCompilerInBrowser = allowInterop((String summaryRoot, | 26 setUpCompilerInBrowser = allowInterop((String sdkUrl, |
27 String sdkUrl, | 27 JSMap<String, String> summaryMap, |
28 List<String> summaryUrls, | |
29 Function onCompileReady, | 28 Function onCompileReady, |
30 Function onError) async { | 29 Function onError) async { |
31 (await _setUpCompilerInBrowser)( | 30 (await _setUpCompilerInBrowser)( |
32 summaryRoot, sdkUrl, summaryUrls, onCompileReady, onError); | 31 sdkUrl, summaryMap, onCompileReady, onError); |
33 }); | 32 }); |
34 _runCommand(args); | 33 _runCommand(args); |
35 } | 34 } |
36 | 35 |
37 /// Runs a single compile command, and returns an exit code. | 36 /// Runs a single compile command, and returns an exit code. |
38 _runCommand(List<String> args, {MessageHandler messageHandler}) { | 37 _runCommand(List<String> args, {MessageHandler messageHandler}) { |
39 try { | 38 try { |
40 // TODO: Remove CommandRunner and args if possible. May run into issues | 39 // TODO: Remove CommandRunner and args if possible. May run into issues |
41 // with ArgResults or ArgParsers. | 40 // with ArgResults or ArgParsers. |
42 var runner = new CommandRunner('dartdevc', 'Dart Development Compiler'); | 41 var runner = new CommandRunner('dartdevc', 'Dart Development Compiler'); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 "any other information that may help us track it down. Thanks!"); | 76 "any other information that may help us track it down. Thanks!"); |
78 messageHandler(""); | 77 messageHandler(""); |
79 messageHandler(" dartdevc arguments: " + args.join(' ')); | 78 messageHandler(" dartdevc arguments: " + args.join(' ')); |
80 messageHandler(""); | 79 messageHandler(""); |
81 messageHandler("```"); | 80 messageHandler("```"); |
82 messageHandler(error); | 81 messageHandler(error); |
83 messageHandler(stackTrace); | 82 messageHandler(stackTrace); |
84 messageHandler("```"); | 83 messageHandler("```"); |
85 } | 84 } |
86 } | 85 } |
OLD | NEW |