summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Aubry2012-10-11 10:13:54 (EDT)
committerSimon Bernard2012-10-11 10:13:54 (EDT)
commitc72da955b095b08c62f01e155bfec158d0a60728 (patch)
tree90612546a6346fdc95dd80639bdb65047c6099b1
parentd9d7e376a3715a391ab83302ba1bb45c92db7ab3 (diff)
downloadorg.eclipse.koneki.ldt-c72da955b095b08c62f01e155bfec158d0a60728.zip
org.eclipse.koneki.ldt-c72da955b095b08c62f01e155bfec158d0a60728.tar.gz
org.eclipse.koneki.ldt-c72da955b095b08c62f01e155bfec158d0a60728.tar.bz2
bug 390674: [remote] Remote launch configuration, support of arguments
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java4
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java45
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java2
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/sshprocess/SshProcess.java19
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteArgumentsTab.java50
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationTabGroup.java7
6 files changed, 98 insertions, 29 deletions
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java
index 4ba159a..8f82d11 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java
@@ -19,9 +19,13 @@ public interface LuaRemoteDebugConstant {
String PROJECT_NAME = ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME;
String SCRIPT_NAME = ScriptLaunchConfigurationConstants.ATTR_MAIN_SCRIPT_NAME;
String HOST_ID = Activator.PLUGIN_ID + ".debug.hostid"; //$NON-NLS-1$
+ String OUTPUT_DIRECTORY = ScriptLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY;
+ String SCRIPT_ARGS = ScriptLaunchConfigurationConstants.ATTR_SCRIPT_ARGUMENTS;
+ String INTERPRETER_ARGS = ScriptLaunchConfigurationConstants.ATTR_INTERPRETER_ARGUMENTS;
String BREAK_ON_FIRST_LINE = ScriptLaunchConfigurationConstants.ENABLE_BREAK_ON_FIRST_LINE;
String DBGP_LOGGING = ScriptLaunchConfigurationConstants.ENABLE_DBGP_LOGGING;
String NATURE = ScriptLaunchConfigurationConstants.ATTR_SCRIPT_NATURE;
+
}
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java
index 5e1bcbe..efc7db3 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java
@@ -15,10 +15,8 @@ import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;
import java.text.MessageFormat;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -121,7 +119,9 @@ public class LuaRemoteLaunchConfigurationDelegate extends LaunchConfigurationDel
if (submonitor.isCanceled())
return;
String outputDirectory = luaSubSystem.getOutputDirectory();
- String remoteApplicationFolderPath = LuaRemoteLaunchConfigurationUtil.getRemoteApplicationPath(configuration);
+ String defaultRemoteApplicationFolderPath = outputDirectory + remoteFileSubSystem.getSeparator() + configuration.getName();
+ String remoteApplicationFolderPath = configuration.getAttribute(LuaRemoteDebugConstant.OUTPUT_DIRECTORY,
+ defaultRemoteApplicationFolderPath);
// compute script file source path relative path
String scriptProjectRelativePath = configuration.getAttribute(LuaRemoteDebugConstant.SCRIPT_NAME, LuaConstants.DEFAULT_MAIN_FILE);
@@ -243,20 +243,39 @@ public class LuaRemoteLaunchConfigurationDelegate extends LaunchConfigurationDel
}
// create lua execution command
- List<String> cmd = new ArrayList<String>(6);
- // FIXME is there a cleaner way to control buffering ?
- // see: http://lua-users.org/lists/lua-l/2011-05/msg00549.html
- String bootstrapCode = "io.stdout:setvbuf(\"line\");"; //$NON-NLS-1$
+ StringBuilder cmd = new StringBuilder();
// create command to run
- cmd.add(luaSubSystem.getLuaCommand());
+ cmd.append(luaSubSystem.getLuaCommand());
+ cmd.append(SshProcess.ARGUMENT_SEPARATOR);
+
+ // insert interpreter args
+ String interpreterArgs = configuration.getAttribute(LuaRemoteDebugConstant.INTERPRETER_ARGS, ""); //$NON-NLS-1$
+ if (!interpreterArgs.isEmpty()) {
+ cmd.append(interpreterArgs);
+ cmd.append(SshProcess.ARGUMENT_SEPARATOR);
+ }
+
+ // FIXME is there a cleaner way to control buffering ?
+ // see: http://lua-users.org/lists/lua-l/2011-05/msg00549.html
+ String bootstrapCode = "io.stdout:setvbuf('line');"; //$NON-NLS-1$
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
// load debugging libraries. The -l parameter cannot be used here because the debugger MUST be the first module to be loaded
- bootstrapCode += " require(\"" + DEBGUGGER_MODULE + "\")();"; //$NON-NLS-1$//$NON-NLS-2$
+ bootstrapCode += " require('" + DEBGUGGER_MODULE + "')();"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+ cmd.append("-e"); //$NON-NLS-1$
+ cmd.append(SshProcess.ARGUMENT_SEPARATOR);
+ cmd.append("\"" + bootstrapCode + "\""); //$NON-NLS-1$//$NON-NLS-2$
+ cmd.append(SshProcess.ARGUMENT_SEPARATOR);
+ cmd.append(SshProcess.escapeShell(scriptSourcePathRelativePath.toPortableString()));
+ cmd.append(SshProcess.ARGUMENT_SEPARATOR);
+
+ // insert script args
+ String scriptArgs = configuration.getAttribute(LuaRemoteDebugConstant.SCRIPT_ARGS, ""); //$NON-NLS-1$
+ if (!scriptArgs.isEmpty()) {
+ cmd.append(scriptArgs);
+ cmd.append(SshProcess.ARGUMENT_SEPARATOR);
}
- cmd.add("-e"); //$NON-NLS-1$
- cmd.add(bootstrapCode);
- cmd.add(scriptSourcePathRelativePath.toPortableString());
submonitor.setWorkRemaining(1);
@@ -264,7 +283,7 @@ public class LuaRemoteLaunchConfigurationDelegate extends LaunchConfigurationDel
if (submonitor.isCanceled())
return;
- SshProcess process = new SshProcess(session, launch, remoteApplicationFolderPath, cmd.toArray(new String[cmd.size()]), envVars);
+ SshProcess process = new SshProcess(session, launch, remoteApplicationFolderPath, cmd.toString(), envVars);
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
// Desactivate DBGP Stream redirection
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java
index ab520d5..1663680 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java
@@ -165,7 +165,7 @@ public final class LuaRemoteLaunchConfigurationUtil {
return null;
}
- public static String getRemoteApplicationPath(ILaunchConfiguration configuration) throws CoreException {
+ public static String getRemoteApplicationPath(ILaunchConfiguration configuration) {
IHost host = getHost(configuration);
IRemoteFileSubSystem remoteFileSubSystem = RSEUtil.getRemoteFileSubsystem(host);
LuaSubSystem luaSubSystem = LuaRSEUtil.getLuaSubSystem(host);
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/sshprocess/SshProcess.java b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/sshprocess/SshProcess.java
index 865b22d..a47db70 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/sshprocess/SshProcess.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/sshprocess/SshProcess.java
@@ -36,6 +36,8 @@ import com.jcraft.jsch.Session;
*/
public class SshProcess implements IProcess {
+ public static final char ARGUMENT_SEPARATOR = ' ';
+
private ILaunch launch;
private ChannelExec channelExec;
private StreamsProxy sshStreamProxy;
@@ -55,8 +57,7 @@ public class SshProcess implements IProcess {
* @throws CoreException
* if exec channel can not be created, or session is down
*/
- public SshProcess(Session session, ILaunch launch, String workingDirectoryPath, String[] command, Map<String, String> envVars)
- throws CoreException {
+ public SshProcess(Session session, ILaunch launch, String workingDirectoryPath, String command, Map<String, String> envVars) throws CoreException {
this.launch = launch;
this.currentSession = session;
this.workingDir = workingDirectoryPath;
@@ -72,12 +73,7 @@ public class SshProcess implements IProcess {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to create SShProcess")); //$NON-NLS-1$
channelExec = (ChannelExec) channel;
- // Create command label (unescaped form)
- StringBuilder labelCmd = new StringBuilder();
- for (String part : command) {
- labelCmd.append(part).append(" "); //$NON-NLS-1$
- }
- this.label = labelCmd.toString();
+ this.label = command;
// create composed command
String composedCommand = createLaunchCommand(workingDirectoryPath, command, envVars);
@@ -145,7 +141,7 @@ public class SshProcess implements IProcess {
/**
* create one command from workingdir, envpath and command
*/
- private String createLaunchCommand(String workingDirectoryPath, String[] command, Map<String, String> envVars) {
+ private String createLaunchCommand(String workingDirectoryPath, String command, Map<String, String> envVars) {
// TODO : should works only on linux...
StringBuilder composedCommand = new StringBuilder();
@@ -177,9 +173,8 @@ public class SshProcess implements IProcess {
// launch command in background
composedCommand.append("{ "); //$NON-NLS-1$
- for (String part : command) {
- composedCommand.append(escapeShell(part)).append(" "); //$NON-NLS-1$
- }
+ composedCommand.append(command);
+
composedCommand.append(" & }"); //$NON-NLS-1$
composedCommand.append(" && "); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteArgumentsTab.java b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteArgumentsTab.java
new file mode 100644
index 0000000..044403c
--- /dev/null
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteArgumentsTab.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sierra Wireless and others.
+ * 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:
+ * Sierra Wireless - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.koneki.ldt.remote.debug.ui.internal.launch.tab;
+
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.dltk.debug.ui.launchConfigurations.ScriptArgumentsTab;
+import org.eclipse.dltk.debug.ui.messages.ScriptLaunchMessages;
+import org.eclipse.dltk.internal.debug.ui.launcher.WorkingDirectoryBlock;
+import org.eclipse.koneki.ldt.remote.debug.core.internal.launch.LuaRemoteLaunchConfigurationUtil;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+public class LuaRemoteArgumentsTab extends ScriptArgumentsTab implements ILaunchConfigurationTab {
+ @Override
+ protected WorkingDirectoryBlock createWorkingDirBlock() {
+ return new WorkingDirectoryBlock() {
+
+ @Override
+ protected void setDefaultWorkingDir() {
+ ILaunchConfiguration configuration = getCurrentLaunchConfiguration();
+ setDefaultWorkingDirectoryText(LuaRemoteLaunchConfigurationUtil.getRemoteApplicationPath(configuration));
+ }
+
+ @Override
+ protected Button createPushButton(Composite parent, String label, Image image) {
+ Button button = super.createPushButton(parent, label, image);
+ if (label.equals(ScriptLaunchMessages.WorkingDirectoryBlock_0) || label.equals(ScriptLaunchMessages.WorkingDirectoryBlock_1)
+ || label.equals(ScriptLaunchMessages.WorkingDirectoryBlock_17)) {
+ button.setVisible(false);
+ }
+ return button;
+ }
+
+ @Override
+ public boolean isValid(ILaunchConfiguration config) {
+ return true;
+ }
+ };
+ }
+}
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationTabGroup.java b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationTabGroup.java
index 1afacee..acf789f 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationTabGroup.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationTabGroup.java
@@ -12,10 +12,11 @@ public class LuaRemoteLaunchConfigurationTabGroup extends AbstractLaunchConfigur
@Override
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
- ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[3];
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[4];
tabs[0] = new LuaRemoteLaunchConfigurationMainTab(mode);
- tabs[1] = new LuaRemoteEnvironmentTab();
- tabs[2] = new CommonTab();
+ tabs[1] = new LuaRemoteArgumentsTab();
+ tabs[2] = new LuaRemoteEnvironmentTab();
+ tabs[3] = new CommonTab();
setTabs(tabs);
}