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

Side by Side Diff: samples/total/server/DartCompiler.dart

Issue 10635015: Delete proxy and total samples, which have bit-rotted. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « samples/total/client/total.css ('k') | samples/total/server/GetSpreadsheet.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #library("total:dartcompiler");
6
7 #import('dart:io');
8
9 /**
10 * A simple wrapper around the Dart compiler (runs dart2js).
11 * TODO: automatically determine the exec path
12 */
13 class DartCompiler {
14 final DART2JS_EXECS = const [
15 '../../../xcodebuild/ReleaseIA32/dart-sdk/bin/dart2js',
16 '../../../out/ReleaseIA32/dart-sdk/bin/dart2js'];
17
18 String scriptName;
19 String out = null;
20 bool warningsAsErrors = false;
21 bool enableTypeChecks = false;
22 bool checkOnly = false;
23
24 String _dart2jsExecPath;
25
26 DartCompiler(String this.scriptName) {
27 for (var path in DART2JS_EXECS) {
28 var f = new File(path);
29 if (f.existsSync()) {
30 _dart2jsExecPath = path;
31 break;
32 }
33 }
34 if (_dart2jsExecPath == null) {
35 throw new Exception("Can't find dart2js on path: " + DART2JS_EXECS);
36 }
37 }
38
39 void compile(void callback(int exitCode, String errorOutput)) {
40 List<String> args = new List<String>();
41
42 args.add("--compile-only");
43
44 if (out != null) {
45 args.add('--out=' + out);
46 }
47 if (warningsAsErrors) {
48 args.add('--warnings_as_errors');
49 }
50 if (enableTypeChecks) {
51 args.add('--enable_type_checks');
52 }
53 if (checkOnly) {
54 args.add('--check-only');
55 }
56
57
58 args.add(scriptName);
59
60 Process compiler = new Process.start(_dart2jsExecPath, args);
61 StringBuffer messages = new StringBuffer();
62 compiler.onExit = (int status) {
63 compiler.close();
64 callback(status, messages.toString());
65 };
66
67 compiler.stdout.onData = () => _readAll(compiler.stdout, messages);
68 compiler.stderr.onData = () => _readAll(compiler.stderr, messages);
69 }
70 }
71
72 void _readAll(InputStream input, StringBuffer output) {
73 while (input.available() != 0) {
74 output.add(new String.fromCharCodes(input.read()));
75 }
76 }
77
OLDNEW
« no previous file with comments | « samples/total/client/total.css ('k') | samples/total/server/GetSpreadsheet.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698