Skip to main content
summaryrefslogtreecommitdiffstats
path: root/launch
diff options
context:
space:
mode:
authorJeff Johnston2018-06-01 18:10:03 -0400
committerJeff Johnston2018-06-02 10:34:52 -0400
commitcf25db1d3498ca93a5608ef5dbd392ac73de3076 (patch)
tree5ac4cda44a1ca3098d60e13900548a6c9a6062b9 /launch
parent06bb3101df215bdcc6438d25f4420c0ef08a5d43 (diff)
downloadorg.eclipse.cdt-cf25db1d3498ca93a5608ef5dbd392ac73de3076.tar.gz
org.eclipse.cdt-cf25db1d3498ca93a5608ef5dbd392ac73de3076.tar.xz
org.eclipse.cdt-cf25db1d3498ca93a5608ef5dbd392ac73de3076.zip
Bug 535473 - Run/Debug buttons for Container target don't run/debug
- Launch bar is usually expecting a LaunchConfigurationTargeted Delegate which calculates the binary but Container build uses the ContainerLaunchConfigurationDelegate which expects the program name, working dir, connection, and image id set up as ILaunchConfiguration attributes - modify ContainerLaunchConfigurationDelegate to add finalLaunchCheck method which can verify if the launch config attributes are set up and if not, set them from the build config (since this is post-build) - fix getImageName() in CoreBuildContainerLaunchConfigProvider to use toolchain attributes Change-Id: Iad6cc26928c33e964650b99844e065df8653858f
Diffstat (limited to 'launch')
-rw-r--r--launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerLaunchConfigurationDelegate.java57
-rw-r--r--launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ui/launchbar/CoreBuildContainerLaunchConfigProvider.java17
2 files changed, 69 insertions, 5 deletions
diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerLaunchConfigurationDelegate.java b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerLaunchConfigurationDelegate.java
index f9a93fec13..73872226ca 100644
--- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerLaunchConfigurationDelegate.java
+++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerLaunchConfigurationDelegate.java
@@ -27,6 +27,7 @@ import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager;
+import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.docker.launcher.ContainerTargetTypeProvider;
@@ -607,6 +608,62 @@ public class ContainerLaunchConfigurationDelegate extends GdbLaunchDelegate
}
@Override
+ public boolean finalLaunchCheck(ILaunchConfiguration configuration,
+ String mode, IProgressMonitor monitor) throws CoreException {
+ IProject project = getProject(configuration);
+ ILaunchTargetManager targetManager = CCorePlugin
+ .getService(ILaunchTargetManager.class);
+ ILaunchTarget target = null;
+ ILaunchTarget[] targets = targetManager
+ .getLaunchTargetsOfType(ContainerTargetTypeProvider.TYPE_ID);
+ String image = configuration.getAttribute(
+ IContainerLaunchTarget.ATTR_IMAGE_ID, (String) null);
+ String connection = configuration.getAttribute(
+ IContainerLaunchTarget.ATTR_CONNECTION_URI, (String) null);
+ for (ILaunchTarget t : targets) {
+ if (t.getAttribute(IContainerLaunchTarget.ATTR_IMAGE_ID, "")
+ .equals(image)) {
+ target = t;
+ break;
+ }
+ }
+ String program = configuration.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
+ (String) null);
+ if (program == null) {
+ ICBuildConfiguration cconfig = getBuildConfiguration(configuration,
+ mode, target, monitor);
+ if (cconfig != null) {
+ IBinary[] binaries = cconfig.getBuildOutput();
+ for (IBinary b : binaries) {
+ if (b.isExecutable()
+ && b.getElementName().contains(project.getName())) {
+ ILaunchConfigurationWorkingCopy wc = configuration
+ .getWorkingCopy();
+ wc.setAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
+ b.getResource().getProjectRelativePath()
+ .toString());
+ wc.setMappedResources(new IResource[] { b.getResource(),
+ b.getResource().getProject() });
+ wc.setAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
+ (String) null); // default is the project
+ // directory
+ wc.setAttribute(ILaunchConstants.ATTR_CONNECTION_URI,
+ connection);
+ wc.setAttribute(ILaunchConstants.ATTR_IMAGE, image);
+
+ wc.doSave();
+ break;
+ }
+ }
+ }
+ }
+ return super.finalLaunchCheck(configuration, mode, monitor);
+ }
+
+ @Override
public boolean preLaunchCheck(ILaunchConfiguration config, String mode,
IProgressMonitor monitor) throws CoreException {
String projectName = config.getAttribute(
diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ui/launchbar/CoreBuildContainerLaunchConfigProvider.java b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ui/launchbar/CoreBuildContainerLaunchConfigProvider.java
index 6b51587372..1e9b4e6730 100644
--- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ui/launchbar/CoreBuildContainerLaunchConfigProvider.java
+++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ui/launchbar/CoreBuildContainerLaunchConfigProvider.java
@@ -11,6 +11,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
+import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.docker.launcher.ContainerTargetTypeProvider;
import org.eclipse.cdt.docker.launcher.IContainerLaunchTarget;
@@ -79,11 +80,17 @@ public class CoreBuildContainerLaunchConfigProvider extends AbstractLaunchConfig
private String getImageName(ILaunchConfiguration config)
throws CoreException {
- String connection = config
- .getAttribute(IContainerLaunchTarget.ATTR_CONNECTION_URI, ""); //$NON-NLS-1$
- String image = config.getAttribute(IContainerLaunchTarget.ATTR_IMAGE_ID,
- ""); //$NON-NLS-1$
- String imageName = connection + "-" + image; //$NON-NLS-1$
+ IProject project = config.getMappedResources()[0].getProject();
+ ICBuildConfiguration cconfig = project.getActiveBuildConfig()
+ .getAdapter(ICBuildConfiguration.class);
+ String image = cconfig.getToolChain()
+ .getProperty(IContainerLaunchTarget.ATTR_IMAGE_ID);
+ String connection = cconfig.getToolChain()
+ .getProperty(IContainerLaunchTarget.ATTR_CONNECTION_URI); // $NON-NLS-1$
+ String imageName = "unknown"; //$NON-NLS-1$
+ if (connection != null && image != null) {
+ imageName = connection + "-" + image; //$NON-NLS-1$
+ }
return imageName;
}

Back to the top