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

Side by Side Diff: bin/devrun.dart

Issue 1268813003: format with dart_style 0.2.0 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 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 | lib/src/codegen/html_codegen.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) 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 /// Runs io.js with dev_compiler's generated code. 6 /// Runs io.js with dev_compiler's generated code.
7 library dev_compiler.bin.devrun; 7 library dev_compiler.bin.devrun;
8 8
9 import 'dart:io'; 9 import 'dart:io';
10 10
11 import 'package:dev_compiler/src/compiler.dart' show validateOptions, compile; 11 import 'package:dev_compiler/src/compiler.dart' show validateOptions, compile;
12 import 'package:dev_compiler/src/options.dart'; 12 import 'package:dev_compiler/src/options.dart';
13 import 'package:dev_compiler/src/runner/runtime_utils.dart' show 13 import 'package:dev_compiler/src/runner/runtime_utils.dart'
14 listOutputFiles, getMainModuleName; 14 show listOutputFiles, getMainModuleName;
15 import 'package:dev_compiler/src/runner/v8_runner.dart' show V8Runner; 15 import 'package:dev_compiler/src/runner/v8_runner.dart' show V8Runner;
16 16
17 import 'package:path/path.dart'; 17 import 'package:path/path.dart';
18 18
19
20 void _showUsageAndExit() { 19 void _showUsageAndExit() {
21 print('usage: dartdevrun [<options>] <file.dart>\n'); 20 print('usage: dartdevrun [<options>] <file.dart>\n');
22 print('<file.dart> is a single Dart file to run.\n'); 21 print('<file.dart> is a single Dart file to run.\n');
23 print('<options> include:\n'); 22 print('<options> include:\n');
24 print(argParser.usage); 23 print(argParser.usage);
25 exit(1); 24 exit(1);
26 } 25 }
27 26
28 main(List<String> args) async { 27 main(List<String> args) async {
29 args = []..add('--arrow-fn-bind-this')..addAll(args); 28 args = []
29 ..add('--arrow-fn-bind-this')
30 ..addAll(args);
30 31
31 CompilerOptions options = validateOptions(args, forceOutDir: true); 32 CompilerOptions options = validateOptions(args, forceOutDir: true);
32 if (options == null || options.help) { 33 if (options == null || options.help) {
33 _showUsageAndExit(); 34 _showUsageAndExit();
34 } 35 }
35 if (options.inputs.length != 1) { 36 if (options.inputs.length != 1) {
36 stderr.writeln("Please only specify one input to run"); 37 stderr.writeln("Please only specify one input to run");
37 _showUsageAndExit(); 38 _showUsageAndExit();
38 } 39 }
39 var runner = new V8Runner(options); 40 var runner = new V8Runner(options);
40 41
41 if (!await compile(options)) exit(1); 42 if (!await compile(options)) exit(1);
42 43
43 var files = await listOutputFiles(options); 44 var files = await listOutputFiles(options);
44 var startStatement = 'dart_library.start("${getMainModuleName(options)}");'; 45 var startStatement = 'dart_library.start("${getMainModuleName(options)}");';
45 46
46 // TODO(ochafik): Only generate the html when some flag is set. 47 // TODO(ochafik): Only generate the html when some flag is set.
47 await _writeHtmlRunner(options, files, startStatement); 48 await _writeHtmlRunner(options, files, startStatement);
48 49
49 // Give our soul (and streams) away to iojs. 50 // Give our soul (and streams) away to iojs.
50 Process process = await runner.start(files, startStatement); 51 Process process = await runner.start(files, startStatement);
51 stdin.pipe(process.stdin); 52 stdin.pipe(process.stdin);
52 stdout.addStream(process.stdout); 53 stdout.addStream(process.stdout);
53 stderr.addStream(process.stderr); 54 stderr.addStream(process.stderr);
54 exit(await process.exitCode); 55 exit(await process.exitCode);
55 } 56 }
56 57
57 /// Generates an HTML file that can be used to run the output with Chrome Dev. 58 /// Generates an HTML file that can be used to run the output with Chrome Dev.
58 _writeHtmlRunner(CompilerOptions options, List<File> files, 59 _writeHtmlRunner(
59 String startStatement) async { 60 CompilerOptions options, List<File> files, String startStatement) async {
60 String outputDir = options.codegenOptions.outputDir; 61 String outputDir = options.codegenOptions.outputDir;
61 String htmlOutput = join(outputDir, "run.html"); 62 String htmlOutput = join(outputDir, "run.html");
62 await new File(htmlOutput).writeAsString(''' 63 await new File(htmlOutput).writeAsString('''
63 <html><head></head><body> 64 <html><head></head><body>
64 ${files.map((f) => 65 ${files.map((f) =>
65 '<script src="${relative(f.path, from: outputDir)}"></script>') 66 '<script src="${relative(f.path, from: outputDir)}"></script>')
66 .join("\n")} 67 .join("\n")}
67 <script>$startStatement</script> 68 <script>$startStatement</script>
68 </body></html> 69 </body></html>
69 '''); 70 ''');
70 71
71 stderr.writeln( 72 stderr.writeln(
72 'Wrote $htmlOutput. It can be opened in Chrome Dev with the following flag s:\n' 73 'Wrote $htmlOutput. It can be opened in Chrome Dev with the following flag s:\n'
73 '--js-flags="--harmony-arrow-functions ' 74 '--js-flags="--harmony-arrow-functions '
74 '--harmony-classes ' 75 '--harmony-classes '
75 '--harmony-computed-property-names ' 76 '--harmony-computed-property-names '
76 '--harmony-spreadcalls"' 77 '--harmony-spreadcalls"'
77 '\n'); 78 '\n');
78 } 79 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/codegen/html_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698