Skip to content

Commit

Permalink
gdx-jnigen, fixed hang when process outputs to err stream, fixed star…
Browse files Browse the repository at this point in the history
…ting process (working dir was not being respected for me!).
  • Loading branch information
NathanSweet committed Jan 4, 2013
1 parent c6bfc62 commit f00cefa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
/extensions/gdx-controllers/gdx-controllers/bin
/extensions/gdx-controllers/gdx-controllers-desktop/bin
/extensions/gdx-controllers/gdx-controllers-desktop/jni/target
/extensions/gdx-controllers/gdx-controllers-desktop/libs/windows32

/gdx/target
/gdx/obj
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class BuildExecutor {
public static void executeAnt (String buildFile, String params) {
FileDescriptor build = new FileDescriptor(buildFile);
String ant = System.getProperty("os.name").contains("Windows") ? "ant.bat" : "ant";
String command = ant + " -f " + build.name() + " " + params;
String command = ant + " -f " + build.file().getAbsolutePath() + " " + params;
System.out.println("Executing '" + command + "'");
startProcess(command, build.parent().file());
}
Expand All @@ -47,7 +47,8 @@ public static void executeNdk (String directory) {

private static void startProcess (String command, File directory) {
try {
final Process process = Runtime.getRuntime().exec(command, null, directory);
final Process process = new ProcessBuilder(command.split(" ")).redirectErrorStream(true).start();

Thread t = new Thread(new Runnable() {
@Override
public void run () {
Expand Down Expand Up @@ -134,7 +135,6 @@ private int getLineNumber (String line) {
});
t.setDaemon(true);
t.start();
// FIXME this will hang if Ant detects an error while executing GCC in a process. Why?
process.waitFor();
} catch (Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit f00cefa

Please sign in to comment.