[Esbox-commits] r400 - in trunk/org.indt.esbox.core/src/org/indt/esbox/core: scratchbox tool/oprofile tool/valgrind
raul at garage.maemo.org
raul at garage.maemo.org
Wed Feb 13 22:22:40 EET 2008
Author: raul
Date: 2008-02-13 22:22:26 +0200 (Wed, 13 Feb 2008)
New Revision: 400
Added:
trunk/org.indt.esbox.core/src/org/indt/esbox/core/scratchbox/ESboxCommonCommandLauncher.java
Removed:
trunk/org.indt.esbox.core/src/org/indt/esbox/core/scratchbox/SbrshCommandLauncher.java
Modified:
trunk/org.indt.esbox.core/src/org/indt/esbox/core/scratchbox/ScratchboxCommandLauncher.java
trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/oprofile/OPreportToolRunner.java
trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/oprofile/OProfileToolRunner.java
trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/valgrind/ValgrindToolRunner.java
Log:
EbrshCommandLauncher renamed to ESboxCommonCommandLauncher. Fixies on ToolRunners.
Copied: trunk/org.indt.esbox.core/src/org/indt/esbox/core/scratchbox/ESboxCommonCommandLauncher.java (from rev 398, trunk/org.indt.esbox.core/src/org/indt/esbox/core/scratchbox/SbrshCommandLauncher.java)
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/scratchbox/ESboxCommonCommandLauncher.java (rev 0)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/scratchbox/ESboxCommonCommandLauncher.java 2008-02-13 20:22:26 UTC (rev 400)
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.core.scratchbox;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.eclipse.cdt.utils.pty.PTY;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+import org.eclipse.core.runtime.IPath;
+import org.indt.esbox.core.StreamMonitor;
+import org.indt.esbox.core.tool.ToolRunnerInfo;
+
+/**
+ *
+ */
+public class ESboxCommonCommandLauncher extends ScratchboxCommandLauncher {
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.core.CommandLauncher#execute(org.eclipse.core.runtime.IPath, java.lang.String[], java.lang.String[], org.eclipse.core.runtime.IPath)
+ */
+ public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory) {
+ try {
+ fCommandArgs = constructCommandArray(commandPath.toOSString(),args, env, changeToDirectory);
+
+ PTY pty = new PTY();
+ fProcess = ProcessFactory.getFactory().exec(fCommandArgs, new String[] {}, changeToDirectory.toFile(), new PTY());
+
+ fErrorMessage = "";
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ setErrorMessage(e.getMessage());
+ fProcess = null;
+ }
+
+ return fProcess;
+ }
+
+ public Process execute(ToolRunnerInfo toolInfo) {
+ try {
+ List<String> cmdLine = toolInfo.getCommandLine();
+ String command = cmdLine.get(0);
+ String args[] = new String[toolInfo.getCommandLine().size() - 1];
+
+ for (int i = 1; i < cmdLine.size(); i++) {
+ args[i - 1] = cmdLine.get(i);
+ }
+
+ String env[] = getEnvArray(toolInfo.getEnvVars());
+
+ fCommandArgs = constructCommandArray(command, args, env, toolInfo.getCwd());
+ fProcess = Runtime.getRuntime().exec(fCommandArgs);
+
+ if (toolInfo.isSendToConsole()) {
+ // print all output to console
+ new StreamMonitor(fProcess.getInputStream(), toolInfo.isBrandNew(), toolInfo.getConsoleName());
+ // print all errors to console
+ new StreamMonitor(fProcess.getErrorStream(), toolInfo.isBrandNew(), toolInfo.getConsoleName());
+ }
+
+ fErrorMessage = "";
+ } catch (IOException e) {
+ setErrorMessage(e.getMessage());
+ fProcess = null;
+ }
+
+ return fProcess;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher#constructCommandArray(java.lang.String, java.lang.String[], java.lang.String[], org.eclipse.core.runtime.IPath)
+ */
+ protected String[] constructCommandArray(String command,
+ String[] commandArgs, String[] env, IPath changeToDirectory)
+ throws IOException {
+
+ String argString = "";
+ // Construct commands arguments to string
+ for (int i = 0; i < commandArgs.length; i++) {
+ argString = argString.concat(" " + commandArgs[i]);
+ }
+
+ // construct whole command with exports
+ String cmd[] = constructCommandArray(command);
+
+ // Replace some pieces of original string
+ cmd[2] = cmd[2] + " " + argString;
+
+ return cmd;
+ }
+
+}
Deleted: trunk/org.indt.esbox.core/src/org/indt/esbox/core/scratchbox/SbrshCommandLauncher.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/scratchbox/SbrshCommandLauncher.java 2008-02-11 18:03:03 UTC (rev 399)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/scratchbox/SbrshCommandLauncher.java 2008-02-13 20:22:26 UTC (rev 400)
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 INdT.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
- *******************************************************************************/
-package org.indt.esbox.core.scratchbox;
-
-import java.io.IOException;
-
-import org.eclipse.cdt.utils.pty.PTY;
-import org.eclipse.cdt.utils.spawner.ProcessFactory;
-import org.eclipse.core.runtime.IPath;
-
-/**
- *
- */
-public class SbrshCommandLauncher extends ScratchboxCommandLauncher {
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.cdt.core.CommandLauncher#execute(org.eclipse.core.runtime.IPath, java.lang.String[], java.lang.String[], org.eclipse.core.runtime.IPath)
- */
- public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory) {
- try {
- fCommandArgs = constructCommandArray(commandPath.toOSString(),args, env, changeToDirectory);
-
- PTY pty = new PTY();
- fProcess = ProcessFactory.getFactory().exec(fCommandArgs, new String[] {}, changeToDirectory.toFile(), new PTY());
-
- fErrorMessage = "";
-
- } catch (IOException e) {
- e.printStackTrace();
- setErrorMessage(e.getMessage());
- fProcess = null;
- }
-
- return fProcess;
- }
-
- /*
- * (non-Javadoc)
- * @see org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher#constructCommandArray(java.lang.String, java.lang.String[], java.lang.String[], org.eclipse.core.runtime.IPath)
- */
- protected String[] constructCommandArray(String command,
- String[] commandArgs, String[] env, IPath changeToDirectory)
- throws IOException {
-
- String argString = "";
- // Construct commands arguments to string
- for (int i = 0; i < commandArgs.length; i++) {
- argString = argString.concat(" " + commandArgs[i]);
- }
-
- // construct whole command with exports
- String cmd[] = constructCommandArray(command);
-
- // Replace some pieces of original string
- cmd[2] = cmd[2] + " " + argString;
-
- return cmd;
- }
-
-}
Modified: trunk/org.indt.esbox.core/src/org/indt/esbox/core/scratchbox/ScratchboxCommandLauncher.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/scratchbox/ScratchboxCommandLauncher.java 2008-02-11 18:03:03 UTC (rev 399)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/scratchbox/ScratchboxCommandLauncher.java 2008-02-13 20:22:26 UTC (rev 400)
@@ -34,6 +34,7 @@
import org.eclipse.core.runtime.Preferences;
import org.indt.esbox.core.CoreActivator;
import org.indt.esbox.core.ESboxPreferenceConstants;
+import org.indt.esbox.core.StreamMonitor;
import org.indt.esbox.core.env.ESboxEnvironmentVariableManager;
import org.indt.esbox.core.tool.ToolRunnerInfo;
@@ -288,6 +289,13 @@
fCommandArgs = constructCommandArray(command, args, env, toolInfo.getCwd());
fProcess = Runtime.getRuntime().exec(fCommandArgs);
+
+ if (toolInfo.isSendToConsole()) {
+ // print all output to console
+ new StreamMonitor(fProcess.getInputStream(), toolInfo.isBrandNew(), toolInfo.getConsoleName());
+ // print all errors to console
+ new StreamMonitor(fProcess.getErrorStream(), toolInfo.isBrandNew(), toolInfo.getConsoleName());
+ }
fErrorMessage = "";
} catch (IOException e) {
@@ -298,7 +306,7 @@
return fProcess;
}
- private String[] getEnvArray(Properties env) {
+ protected String[] getEnvArray(Properties env) {
List<String> envList = new ArrayList<String>();
Enumeration names = env.propertyNames();
if (names != null) {
Modified: trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/oprofile/OPreportToolRunner.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/oprofile/OPreportToolRunner.java 2008-02-11 18:03:03 UTC (rev 399)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/oprofile/OPreportToolRunner.java 2008-02-13 20:22:26 UTC (rev 400)
@@ -52,6 +52,11 @@
public void trackProcess(Process process) throws ESboxException {
sendToolExecutedSignal(process);
+ try {
+ process.waitFor();
+ } catch (InterruptedException e) {
+ throw new ESboxException(e);
+ }
}
public synchronized void addListener(IToolListener l) {
Modified: trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/oprofile/OProfileToolRunner.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/oprofile/OProfileToolRunner.java 2008-02-11 18:03:03 UTC (rev 399)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/oprofile/OProfileToolRunner.java 2008-02-13 20:22:26 UTC (rev 400)
@@ -45,13 +45,18 @@
List<String> commandLine = runnerInfo.getCommandLine();
commandLine.add(OPROFILE);
runnerInfo.setBrandNew(false);
- runnerInfo.setSendToConsole(false);
- runnerInfo.setConsoleName(null);
+ runnerInfo.setSendToConsole(true);
+ runnerInfo.setConsoleName("OProfile Tool");
return runnerInfo;
}
public void trackProcess(Process process) throws ESboxException {
sendToolExecutedSignal(process);
+ try {
+ process.waitFor();
+ } catch (InterruptedException e) {
+ throw new ESboxException(e);
+ }
}
public synchronized void addListener(IToolListener l) {
Modified: trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/valgrind/ValgrindToolRunner.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/valgrind/ValgrindToolRunner.java 2008-02-11 18:03:03 UTC (rev 399)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/valgrind/ValgrindToolRunner.java 2008-02-13 20:22:26 UTC (rev 400)
@@ -45,13 +45,18 @@
List<String> commandLine = runnerInfo.getCommandLine();
commandLine.add(VALGRIND);
runnerInfo.setBrandNew(false);
- runnerInfo.setSendToConsole(false);
- runnerInfo.setConsoleName(null);
+ runnerInfo.setSendToConsole(true);
+ runnerInfo.setConsoleName("Valgrind Tool");
return runnerInfo;
}
public void trackProcess(Process process) throws ESboxException {
sendToolExecutedSignal(process);
+ try {
+ process.waitFor();
+ } catch (InterruptedException e) {
+ throw new ESboxException(e);
+ }
}
public synchronized void addListener(IToolListener l) {
More information about the Esbox-commits
mailing list