| 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 28 matching lines...) Expand all Loading... |
| 39 args.add('-fatal-type-errors'); | 39 args.add('-fatal-type-errors'); |
| 40 } | 40 } |
| 41 if (optimize) { | 41 if (optimize) { |
| 42 args.add('-optimize'); | 42 args.add('-optimize'); |
| 43 } | 43 } |
| 44 if (checkOnly) { | 44 if (checkOnly) { |
| 45 args.add('-check-only'); | 45 args.add('-check-only'); |
| 46 } | 46 } |
| 47 args.add(scriptName); | 47 args.add(scriptName); |
| 48 | 48 |
| 49 Process compiler = new Process(DARTC_EXEC_PATH, args); | 49 Process compiler = new Process.start(DARTC_EXEC_PATH, args); |
| 50 | |
| 51 StringBuffer messages = new StringBuffer(); | 50 StringBuffer messages = new StringBuffer(); |
| 52 compiler.exitHandler = (int status) { | 51 compiler.exitHandler = (int status) { |
| 53 compiler.close(); | 52 compiler.close(); |
| 54 callback(status, messages.toString()); | 53 callback(status, messages.toString()); |
| 55 }; | 54 }; |
| 56 | |
| 57 compiler.start(); | |
| 58 | 55 |
| 59 compiler.stdout.dataHandler = () => _readAll(compiler.stdout, messages); | 56 compiler.stdout.dataHandler = () => _readAll(compiler.stdout, messages); |
| 60 compiler.stderr.dataHandler = () => _readAll(compiler.stderr, messages); | 57 compiler.stderr.dataHandler = () => _readAll(compiler.stderr, messages); |
| 61 } | 58 } |
| 62 } | 59 } |
| 63 | 60 |
| 64 void _readAll(InputStream input, StringBuffer output) { | 61 void _readAll(InputStream input, StringBuffer output) { |
| 65 while (input.available() != 0) { | 62 while (input.available() != 0) { |
| 66 output.add(new String.fromCharCodes(input.read())); | 63 output.add(new String.fromCharCodes(input.read())); |
| 67 } | 64 } |
| 68 } | 65 } |
| 69 | 66 |
| OLD | NEW |