mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 17:55:39 +02:00
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
This commit is contained in:
parent
06bb3101df
commit
cf25db1d34
2 changed files with 69 additions and 5 deletions
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.build.ICBuildConfiguration;
|
||||||
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
|
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
|
||||||
import org.eclipse.cdt.core.build.IToolChain;
|
import org.eclipse.cdt.core.build.IToolChain;
|
||||||
import org.eclipse.cdt.core.build.IToolChainManager;
|
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.CDebugCorePlugin;
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.docker.launcher.ContainerTargetTypeProvider;
|
import org.eclipse.cdt.docker.launcher.ContainerTargetTypeProvider;
|
||||||
|
@ -606,6 +607,62 @@ public class ContainerLaunchConfigurationDelegate extends GdbLaunchDelegate
|
||||||
return super.buildForLaunch(configuration, mode, monitor);
|
return super.buildForLaunch(configuration, mode, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Override
|
||||||
public boolean preLaunchCheck(ILaunchConfiguration config, String mode,
|
public boolean preLaunchCheck(ILaunchConfiguration config, String mode,
|
||||||
IProgressMonitor monitor) throws CoreException {
|
IProgressMonitor monitor) throws CoreException {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.build.ICBuildConfiguration;
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.docker.launcher.ContainerTargetTypeProvider;
|
import org.eclipse.cdt.docker.launcher.ContainerTargetTypeProvider;
|
||||||
import org.eclipse.cdt.docker.launcher.IContainerLaunchTarget;
|
import org.eclipse.cdt.docker.launcher.IContainerLaunchTarget;
|
||||||
|
@ -79,11 +80,17 @@ public class CoreBuildContainerLaunchConfigProvider extends AbstractLaunchConfig
|
||||||
|
|
||||||
private String getImageName(ILaunchConfiguration config)
|
private String getImageName(ILaunchConfiguration config)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
String connection = config
|
IProject project = config.getMappedResources()[0].getProject();
|
||||||
.getAttribute(IContainerLaunchTarget.ATTR_CONNECTION_URI, ""); //$NON-NLS-1$
|
ICBuildConfiguration cconfig = project.getActiveBuildConfig()
|
||||||
String image = config.getAttribute(IContainerLaunchTarget.ATTR_IMAGE_ID,
|
.getAdapter(ICBuildConfiguration.class);
|
||||||
""); //$NON-NLS-1$
|
String image = cconfig.getToolChain()
|
||||||
String imageName = connection + "-" + image; //$NON-NLS-1$
|
.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;
|
return imageName;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue