mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-16 04:35:45 +02:00
Updated Main Tab for Core Build local launch configurations.
A new Main Tab was created for Core Build local projects based on the Main Tab used for the classic Managed Build projects. It adds these features: * Option to select a different binary. * Option to control launch pre-builds. The default value for the binary is empty string. With empty string the behaviour for binary selection stays the same as it was. The project name is fixed and cannot be changed. A Core Build launch configuration is created with the project and tied to it. There is no option to select a build configuration, because for Core Build projects this is selected via the LaunchBar's Launch Mode. This change relates to #758. It affects all Core Build projects, including CMake projects.
This commit is contained in:
parent
9b6bb0711f
commit
5639ba9ff9
11 changed files with 88 additions and 59 deletions
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.debug.core; singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.debug.core; singleton:=true
|
||||||
Bundle-Version: 8.8.600.qualifier
|
Bundle-Version: 8.8.700.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin
|
Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.core.launch;
|
package org.eclipse.cdt.debug.core.launch;
|
||||||
|
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
@ -23,14 +24,18 @@ import org.eclipse.cdt.core.build.IToolChainManager;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
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.internal.core.InternalDebugCoreMessages;
|
import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages;
|
||||||
import org.eclipse.core.resources.IBuildConfiguration;
|
import org.eclipse.core.resources.IBuildConfiguration;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IProjectDescription;
|
import org.eclipse.core.resources.IProjectDescription;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.core.variables.VariablesPlugin;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||||
import org.eclipse.launchbar.core.target.launch.LaunchConfigurationTargetedDelegate;
|
import org.eclipse.launchbar.core.target.launch.LaunchConfigurationTargetedDelegate;
|
||||||
|
@ -121,6 +126,28 @@ public abstract class CoreBuildLaunchConfigDelegate extends LaunchConfigurationT
|
||||||
return exeFile;
|
return exeFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 8.8
|
||||||
|
*/
|
||||||
|
protected String getProgramPath(ILaunchConfiguration configuration, IBinary exeFile) throws CoreException {
|
||||||
|
String programName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (programName.isBlank()) {
|
||||||
|
return Paths.get(exeFile.getLocationURI()).toString();
|
||||||
|
} else {
|
||||||
|
IPath path = new Path(
|
||||||
|
VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName));
|
||||||
|
String fullPath;
|
||||||
|
if (path.isAbsolute()) {
|
||||||
|
fullPath = path.toOSString();
|
||||||
|
} else {
|
||||||
|
IProject project = getProject(configuration);
|
||||||
|
fullPath = project.getFile(path).getLocation().toOSString();
|
||||||
|
}
|
||||||
|
return fullPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
|
protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
|
||||||
// 1. Extract project from configuration
|
// 1. Extract project from configuration
|
||||||
|
@ -140,6 +167,16 @@ public abstract class CoreBuildLaunchConfigDelegate extends LaunchConfigurationT
|
||||||
@Override
|
@Override
|
||||||
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target,
|
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target,
|
||||||
IProgressMonitor monitor) throws CoreException {
|
IProgressMonitor monitor) throws CoreException {
|
||||||
|
|
||||||
|
// We will never get here if "build before launching" is disabled in the Workspace settings, even if in the
|
||||||
|
// CDT launch configuration "Use workspace settings" is not selected.
|
||||||
|
// The workspace setting is already considered in org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(),
|
||||||
|
// before the settings in the CDT launch configuration.
|
||||||
|
int autoBuild = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, 2);
|
||||||
|
if (autoBuild == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ICBuildConfiguration buildConfig = getBuildConfiguration(configuration, mode, target, monitor);
|
ICBuildConfiguration buildConfig = getBuildConfiguration(configuration, mode, target, monitor);
|
||||||
if (buildConfig != null) {
|
if (buildConfig != null) {
|
||||||
IProject project = getProject(configuration);
|
IProject project = getProject(configuration);
|
||||||
|
|
|
@ -14,6 +14,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.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -66,6 +67,10 @@ public class CoreBuildLocalLaunchConfigProvider extends AbstractLaunchConfigProv
|
||||||
|
|
||||||
// Set the project and the connection
|
// Set the project and the connection
|
||||||
IProject project = descriptor.getAdapter(IProject.class);
|
IProject project = descriptor.getAdapter(IProject.class);
|
||||||
|
// CMainTab2 expects these attributes when calling CLaunchConfigurationTab.getContext()
|
||||||
|
// Using empty string for default Core Build program.
|
||||||
|
workingCopy.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName());
|
||||||
|
workingCopy.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); //$NON-NLS-1$
|
||||||
workingCopy.setMappedResources(new IResource[] { project });
|
workingCopy.setMappedResources(new IResource[] { project });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ package org.eclipse.cdt.debug.internal.core.launch;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -55,7 +54,7 @@ public class CoreBuildLocalRunLaunchDelegate extends CoreBuildLaunchConfigDelega
|
||||||
|
|
||||||
String[] arguments = CommandLineUtil.argumentsToArray(args);
|
String[] arguments = CommandLineUtil.argumentsToArray(args);
|
||||||
List<String> command = new ArrayList<>(1 + arguments.length);
|
List<String> command = new ArrayList<>(1 + arguments.length);
|
||||||
command.add(Paths.get(exeFile.getLocationURI()).toString());
|
command.add(getProgramPath(configuration, exeFile));
|
||||||
command.addAll(Arrays.asList(arguments));
|
command.addAll(Arrays.asList(arguments));
|
||||||
|
|
||||||
ProcessBuilder builder = new ProcessBuilder(command);
|
ProcessBuilder builder = new ProcessBuilder(command);
|
||||||
|
|
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb;singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb;singleton:=true
|
||||||
Bundle-Version: 7.1.300.qualifier
|
Bundle-Version: 7.1.400.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.GdbPlugin
|
Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.GdbPlugin
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.core.runtime,
|
Require-Bundle: org.eclipse.core.runtime,
|
||||||
|
|
|
@ -19,6 +19,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.build.ICBuildConfiguration;
|
import org.eclipse.cdt.core.build.ICBuildConfiguration;
|
||||||
import org.eclipse.cdt.core.build.IToolChain;
|
import org.eclipse.cdt.core.build.IToolChain;
|
||||||
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.debug.core.launch.CoreBuildLaunchConfigDelegate;
|
import org.eclipse.cdt.debug.core.launch.CoreBuildLaunchConfigDelegate;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
|
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
|
||||||
|
@ -86,8 +87,8 @@ public class CoreBuildLocalDebugLaunchDelegate extends CoreBuildLaunchConfigDele
|
||||||
gdbLaunch.setGDBPath(gdbPath != null ? gdbPath.toString() : "gdb"); //$NON-NLS-1$
|
gdbLaunch.setGDBPath(gdbPath != null ? gdbPath.toString() : "gdb"); //$NON-NLS-1$
|
||||||
String gdbVersion = gdbLaunch.getGDBVersion();
|
String gdbVersion = gdbLaunch.getGDBVersion();
|
||||||
|
|
||||||
Path exeFile = Paths.get(getBinary(buildConfig).getLocationURI());
|
IBinary exeFile = getBinary(buildConfig);
|
||||||
gdbLaunch.setProgramPath(exeFile.toString());
|
gdbLaunch.setProgramPath(getProgramPath(configuration, exeFile));
|
||||||
|
|
||||||
gdbLaunch.setServiceFactory(new GdbDebugServicesFactory(gdbVersion, configuration));
|
gdbLaunch.setServiceFactory(new GdbDebugServicesFactory(gdbVersion, configuration));
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.launch; singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.launch; singleton:=true
|
||||||
Bundle-Version: 10.4.600.qualifier
|
Bundle-Version: 10.4.700.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin
|
Bundle-Activator: org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class LaunchMessages extends NLS {
|
||||||
public static String CommonBuildTab_Default;
|
public static String CommonBuildTab_Default;
|
||||||
public static String CommonBuildTab_NotFound;
|
public static String CommonBuildTab_NotFound;
|
||||||
public static String CommonBuildTab_Toolchain;
|
public static String CommonBuildTab_Toolchain;
|
||||||
|
public static String CoreBuildMainTab_Keep_empty_for_auto_selection;
|
||||||
public static String CoreBuildTab_Build;
|
public static String CoreBuildTab_Build;
|
||||||
public static String CoreBuildTab_NoOptions;
|
public static String CoreBuildTab_NoOptions;
|
||||||
public static String CoreFileLaunchDelegate_Launching_postmortem_debugger;
|
public static String CoreFileLaunchDelegate_Launching_postmortem_debugger;
|
||||||
|
|
|
@ -55,6 +55,7 @@ LocalAttachLaunchDelegate_CDT_Launch_Error=CDT Launch Error
|
||||||
CommonBuildTab_Default=Default (%s)
|
CommonBuildTab_Default=Default (%s)
|
||||||
CommonBuildTab_NotFound=No suitable toolchains found
|
CommonBuildTab_NotFound=No suitable toolchains found
|
||||||
CommonBuildTab_Toolchain=Toolchain
|
CommonBuildTab_Toolchain=Toolchain
|
||||||
|
CoreBuildMainTab_Keep_empty_for_auto_selection=keep empty for automatic selection
|
||||||
CoreBuildTab_Build=Build Settings
|
CoreBuildTab_Build=Build Settings
|
||||||
CoreBuildTab_NoOptions=No build options required.
|
CoreBuildTab_NoOptions=No build options required.
|
||||||
CoreFileLaunchDelegate_Launching_postmortem_debugger=Launching postmortem debugger
|
CoreFileLaunchDelegate_Launching_postmortem_debugger=Launching postmortem debugger
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class CMainTab2 extends CAbstractMainTab {
|
||||||
*/
|
*/
|
||||||
protected Combo fCoreTypeCombo;
|
protected Combo fCoreTypeCombo;
|
||||||
|
|
||||||
private final boolean fDontCheckProgram;
|
private boolean fDontCheckProgram;
|
||||||
private final boolean fSpecifyCoreFile;
|
private final boolean fSpecifyCoreFile;
|
||||||
private final boolean fIncludeBuildSettings;
|
private final boolean fIncludeBuildSettings;
|
||||||
|
|
||||||
|
@ -111,6 +111,13 @@ public class CMainTab2 extends CAbstractMainTab {
|
||||||
fIncludeBuildSettings = (flags & INCLUDE_BUILD_SETTINGS) != 0;
|
fIncludeBuildSettings = (flags & INCLUDE_BUILD_SETTINGS) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 10.4
|
||||||
|
*/
|
||||||
|
protected void setDontCheckProgram(boolean dontCheck) {
|
||||||
|
fDontCheckProgram = dontCheck;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
Composite comp = new Composite(parent, SWT.NONE);
|
Composite comp = new Composite(parent, SWT.NONE);
|
||||||
|
|
|
@ -10,73 +10,51 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launch.ui.corebuild;
|
package org.eclipse.cdt.launch.ui.corebuild;
|
||||||
|
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.cdt.launch.ui.CMainTab2;
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
|
||||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
import org.eclipse.swt.widgets.Text;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 9.1
|
* @since 9.1
|
||||||
*/
|
*/
|
||||||
public class CoreBuildMainTab extends AbstractLaunchConfigurationTab {
|
public class CoreBuildMainTab extends CMainTab2 {
|
||||||
|
|
||||||
private Text projectName;
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A Core Build launch configuration is created immediately upon the Core Build project creation.
|
||||||
|
* It cannot be created by hand and it is not duplicatable and can't be renamed.
|
||||||
|
* The launch configuration is tied to the project. The project name may not be changed.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void createControl(Composite parent) {
|
protected void createProjectGroup(Composite parent, int colSpan) {
|
||||||
Composite comp = new Composite(parent, SWT.NONE);
|
super.createProjectGroup(parent, colSpan);
|
||||||
comp.setLayout(new GridLayout());
|
fProjText.setEnabled(false);
|
||||||
|
fProjButton.setVisible(false);
|
||||||
Label label = new Label(comp, SWT.NONE);
|
|
||||||
label.setText("This launch configuration was automatically created.");
|
|
||||||
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
|
||||||
|
|
||||||
label = new Label(comp, SWT.NONE);
|
|
||||||
label.setText("Project:");
|
|
||||||
|
|
||||||
projectName = new Text(comp, SWT.READ_ONLY | SWT.BORDER);
|
|
||||||
projectName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
|
||||||
|
|
||||||
setControl(comp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
|
protected void createExeFileGroup(Composite parent, int colSpan) {
|
||||||
// none
|
super.createExeFileGroup(parent, colSpan);
|
||||||
|
fProgText.setMessage(LaunchMessages.CoreBuildMainTab_Keep_empty_for_auto_selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For Core Build projects the build configuration is hidden and it is selected
|
||||||
|
* via the LaunchBar Launch Mode. We remove the BuildConfigCombo.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initializeFrom(ILaunchConfiguration configuration) {
|
protected void createBuildConfigCombo(Composite parent, int colspan) {
|
||||||
try {
|
fBuildConfigCombo = null;
|
||||||
for (IResource resource : configuration.getMappedResources()) {
|
|
||||||
if (resource instanceof IProject) {
|
|
||||||
projectName.setText(resource.getName());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
LaunchUIPlugin.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't check the program name if it is empty. When the program name is empty the default
|
||||||
|
* CoreBuild binary is used.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
|
public boolean isValid(ILaunchConfiguration config) {
|
||||||
// TODO Auto-generated method stub
|
String programName = fProgText.getText().trim();
|
||||||
|
setDontCheckProgram(programName.isEmpty());
|
||||||
|
return super.isValid(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "Main";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue