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

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: Added module names and bundle names to allow for import statements in the console. 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
« no previous file with comments | « no previous file | web/web_command.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 setUpCompilerInBrowser(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'];
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 {
60 // TODO: Remove CommandRunner and args if possible. May run into issues
61 // with ArgResults or ArgParsers.
65 var runner = new CommandRunner('dartdevc', 'Dart Development Compiler'); 62 var runner = new CommandRunner('dartdevc', 'Dart Development Compiler');
66 runner 63 runner.addCommand(new WebCompileCommand(messageHandler: messageHandler));
67 .addCommand(new WebCompileCommand(onload, messageHandler: messageHandler )); 64 setUpCompilerInBrowser = allowInterop(await runner.run(args));
68 await runner.run(args);
69 } catch (e, s) { 65 } catch (e, s) {
70 return _handleError(e, s, args, messageHandler: messageHandler); 66 return _handleError(e, s, args, messageHandler: messageHandler);
71 } 67 }
72 return 1; 68 return 1;
73 } 69 }
74 70
75 /// Handles [error] in a uniform fashion. Returns the proper exit code and calls 71 /// Handles [error] in a uniform fashion. Returns the proper exit code and calls
76 /// [messageHandler] with messages. 72 /// [messageHandler] with messages.
77 int _handleError(dynamic error, dynamic stackTrace, List<String> args, 73 int _handleError(dynamic error, dynamic stackTrace, List<String> args,
78 {MessageHandler messageHandler}) { 74 {MessageHandler messageHandler}) {
(...skipping 26 matching lines...) Expand all
105 messageHandler(""); 101 messageHandler("");
106 messageHandler(" dartdevc arguments: " + args.join(' ')); 102 messageHandler(" dartdevc arguments: " + args.join(' '));
107 messageHandler(""); 103 messageHandler("");
108 messageHandler("```"); 104 messageHandler("```");
109 messageHandler(error); 105 messageHandler(error);
110 messageHandler(stackTrace); 106 messageHandler(stackTrace);
111 messageHandler("```"); 107 messageHandler("```");
112 return 70; 108 return 70;
113 } 109 }
114 } 110 }
OLDNEW
« no previous file with comments | « no previous file | web/web_command.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698