From 32db8f48ea7ff160938a0d2ef697a4fc8d614e9b Mon Sep 17 00:00:00 2001 From: jdf Date: Mon, 8 Mar 2010 21:14:23 +0000 Subject: [PATCH] Cleanup android build folder, and make it a new tmp folder each time. --- .../app/tools/android/AndroidTool.java | 75 ++++++++++--------- .../app/tools/android/ProcessHelper.java | 7 +- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/android/tool/src/processing/app/tools/android/AndroidTool.java b/android/tool/src/processing/app/tools/android/AndroidTool.java index c2a97859a..45993c499 100644 --- a/android/tool/src/processing/app/tools/android/AndroidTool.java +++ b/android/tool/src/processing/app/tools/android/AndroidTool.java @@ -191,48 +191,51 @@ public class AndroidTool implements Tool, DeviceListener { if (!build.createProject()) { return; } + try { + if (monitor.isCanceled()) { + throw new Cancelled(); + } + monitor.setNote("Building..."); + if (!build.antBuild("debug")) { + return; + } - if (monitor.isCanceled()) { - throw new Cancelled(); - } - monitor.setNote("Building..."); - if (!build.antBuild("debug")) { - return; - } + if (monitor.isCanceled()) { + throw new Cancelled(); + } + monitor.setNote("Waiting for device to become available..."); + final AndroidDevice device = waitForDevice(deviceFuture, monitor); + if (device == null || !device.isAlive()) { + editor.statusError("Device killed or disconnected."); + return; + } - if (monitor.isCanceled()) { - throw new Cancelled(); - } - monitor.setNote("Waiting for device to become available..."); - final AndroidDevice device = waitForDevice(deviceFuture, monitor); - if (device == null || !device.isAlive()) { - editor.statusError("Device killed or disconnected."); - return; - } + device.addListener(this); - device.addListener(this); + if (monitor.isCanceled()) { + throw new Cancelled(); + } + monitor.setNote("Installing sketch on " + device.getId()); + if (!device.installApp(build.getPathForAPK("debug"), editor)) { + editor.statusError("Device killed or disconnected."); + return; + } - if (monitor.isCanceled()) { - throw new Cancelled(); - } - monitor.setNote("Installing sketch on " + device.getId()); - if (!device.installApp(build.getPathForAPK("debug"), editor)) { - editor.statusError("Device killed or disconnected."); - return; - } + if (monitor.isCanceled()) { + throw new Cancelled(); + } + monitor.setNote("Starting sketch on " + device.getId()); + if (startSketch(device)) { + editor.statusNotice("Sketch launched on the " + + (device.isEmulator() ? "emulator" : "phone") + "."); + } else { + editor.statusError("Could not start the sketch."); + } - if (monitor.isCanceled()) { - throw new Cancelled(); + lastRunDevice = device; + } finally { + build.cleanup(); } - monitor.setNote("Starting sketch on " + device.getId()); - if (startSketch(device)) { - editor.statusNotice("Sketch launched on the " - + (device.isEmulator() ? "emulator" : "phone") + "."); - } else { - editor.statusError("Could not start the sketch."); - } - - lastRunDevice = device; } finally { monitor.close(); } diff --git a/android/tool/src/processing/app/tools/android/ProcessHelper.java b/android/tool/src/processing/app/tools/android/ProcessHelper.java index b79016d7c..7745c2fb6 100644 --- a/android/tool/src/processing/app/tools/android/ProcessHelper.java +++ b/android/tool/src/processing/app/tools/android/ProcessHelper.java @@ -35,7 +35,8 @@ class ProcessHelper { this.cmd = cmd; } - public String getCommand() { + @Override + public String toString() { final StringBuffer buffer = new StringBuffer(); for (int i = 0; i < cmd.length; i++) { if (i != 0) { @@ -57,9 +58,9 @@ class ProcessHelper { final StringWriter errWriter = new StringWriter(); final long startTime = System.currentTimeMillis(); - final String prettyCommand = getCommand(); + final String prettyCommand = toString(); System.err.println("ProcessHelper: >>>>> " + Thread.currentThread().getId() - + " " + cmd[0]); + + " " + prettyCommand); final Process process = Runtime.getRuntime().exec(cmd); ProcessRegistry.watch(process); try {