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

Side by Side Diff: web/main.dart

Issue 2208243002: Restructured the set up for the compiling function. Also added room for list of additional summarie… (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 4 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 #!/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 /// Command line entry point for Dart Development Compiler (dartdevc). 6 /// Command line entry point for Dart Development Compiler (dartdevc).
7 /// 7 ///
8 /// Supported commands are 8 /// Supported commands are
9 /// * compile: builds a collection of dart libraries into a single JS module 9 /// * compile: builds a collection of dart libraries into a single JS module
10 /// 10 ///
(...skipping 28 matching lines...) Expand all
39 library dev_compiler.web.main; 39 library dev_compiler.web.main;
40 40
41 import 'dart:async'; 41 import 'dart:async';
42 42
43 import 'package:args/command_runner.dart'; 43 import 'package:args/command_runner.dart';
44 import 'package:js/js.dart'; 44 import 'package:js/js.dart';
45 45
46 import 'web_command.dart'; 46 import 'web_command.dart';
47 47
48 @JS() 48 @JS()
49 external set compileDartExpression(Function function); 49 external set setUp(Function function);
50
51 typedef String CompileFn(String dart);
52 typedef void OnLoadFn(CompileFn compile);
53 50
54 Future main() async { 51 Future main() async {
55 var args = ['compile']; 52 var args = ['compile'];
Jacob 2016/08/03 23:58:31 passing args and using command runner doesn't seem
priscillalee 2016/08/04 16:01:56 I looked into this myself earlier because I was wo
Jacob 2016/08/04 16:27:48 Just add a TODO indicating just that so the next p
priscillalee 2016/08/04 17:56:33 Done.
56 _runCommand((result) { 53 _runCommand(args);
57 compileDartExpression = allowInterop(result);
58 }, args);
59 } 54 }
60 55
61 /// Runs a single compile command, and returns an exit code. 56 /// Runs a single compile command, and returns an exit code.
62 Future<int> _runCommand(OnLoadFn onload, List<String> args, 57 Future<int> _runCommand(List<String> args,
63 {MessageHandler messageHandler}) async { 58 {MessageHandler messageHandler}) async {
64 try { 59 try {
65 var runner = new CommandRunner('dartdevc', 'Dart Development Compiler'); 60 var runner = new CommandRunner('dartdevc', 'Dart Development Compiler');
66 runner 61 runner.addCommand(new WebCompileCommand(messageHandler: messageHandler));
67 .addCommand(new WebCompileCommand(onload, messageHandler: messageHandler )); 62 setUp = allowInterop(await runner.run(args));
68 await runner.run(args);
69 } catch (e, s) { 63 } catch (e, s) {
70 return _handleError(e, s, args, messageHandler: messageHandler); 64 return _handleError(e, s, args, messageHandler: messageHandler);
71 } 65 }
72 return 1; 66 return 1;
73 } 67 }
74 68
75 /// Handles [error] in a uniform fashion. Returns the proper exit code and calls 69 /// Handles [error] in a uniform fashion. Returns the proper exit code and calls
76 /// [messageHandler] with messages. 70 /// [messageHandler] with messages.
77 int _handleError(dynamic error, dynamic stackTrace, List<String> args, 71 int _handleError(dynamic error, dynamic stackTrace, List<String> args,
78 {MessageHandler messageHandler}) { 72 {MessageHandler messageHandler}) {
(...skipping 26 matching lines...) Expand all
105 messageHandler(""); 99 messageHandler("");
106 messageHandler(" dartdevc arguments: " + args.join(' ')); 100 messageHandler(" dartdevc arguments: " + args.join(' '));
107 messageHandler(""); 101 messageHandler("");
108 messageHandler("```"); 102 messageHandler("```");
109 messageHandler(error); 103 messageHandler(error);
110 messageHandler(stackTrace); 104 messageHandler(stackTrace);
111 messageHandler("```"); 105 messageHandler("```");
112 return 70; 106 return 70;
113 } 107 }
114 } 108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698