OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #library("total:dartc"); | 5 #library("total:dartc"); |
6 | 6 |
7 /** | 7 /** |
8 * A simple wrapper around dartc. | 8 * A simple wrapper around dartc. |
9 * TODO: automatically determine the exec path to dartc | 9 * TODO: automatically determine the exec path to dartc |
10 * TODO: prevent ANSI colors from being exposed to the user | 10 * TODO: prevent ANSI colors from being exposed to the user |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 args.add(scriptName); | 47 args.add(scriptName); |
48 | 48 |
49 Process compiler = new Process(DARTC_EXEC_PATH, args); | 49 Process compiler = new Process(DARTC_EXEC_PATH, args); |
50 | 50 |
51 compiler.setExitHandler((int status) { | 51 compiler.setExitHandler((int status) { |
52 StringBuffer messages = new StringBuffer(); | 52 StringBuffer messages = new StringBuffer(); |
53 if(status != 0) { | 53 if(status != 0) { |
54 // TODO(rchandia) increase read size when stream handling works better | 54 // TODO(rchandia) increase read size when stream handling works better |
55 int BUFSIZE = 1; | 55 int BUFSIZE = 1; |
56 | 56 |
57 _readAll(false, compiler.stdoutStream, new List<int>(BUFSIZE), message
s); | 57 _readAll(false, compiler.stdout, new List<int>(BUFSIZE), messages); |
58 _readAll(false, compiler.stderrStream, new List<int>(BUFSIZE), message
s); | 58 _readAll(false, compiler.stderr, new List<int>(BUFSIZE), messages); |
59 } | 59 } |
60 compiler.close(); | 60 compiler.close(); |
61 callback(status, messages.toString()); | 61 callback(status, messages.toString()); |
62 }); | 62 }); |
63 | 63 |
64 compiler.start(); | 64 compiler.start(); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 void _readAll(bool fromCallback, InputStream input, List<int> buffer, StringBuff
er output) { | 68 void _readAll(bool fromCallback, InputStream input, List<int> buffer, StringBuff
er output) { |
69 if (fromCallback) { | 69 if (fromCallback) { |
70 output.add(new String.fromCharCodes(buffer)); | 70 output.add(new String.fromCharCodes(buffer)); |
71 } | 71 } |
72 while (input.read(buffer, 0, buffer.length, () => _readAll(true, input, buffer
, output))) { | 72 while (input.read(buffer, 0, buffer.length, () => _readAll(true, input, buffer
, output))) { |
73 output.add(new String.fromCharCodes(buffer)); | 73 output.add(new String.fromCharCodes(buffer)); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
OLD | NEW |