1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-04 06:03:18 +02:00

Core Build project without binaries. (#959)

Do not check for binaries in the project directory if the user defined
a binary in the Main tab. This supports the case where the user
disables auto build and selects a binary outside the project directory.
Otherwise the binaries check would stop the launch with the message
that no binaries are found in the project.
This commit is contained in:
ewaterlander 2024-12-13 02:15:01 +01:00 committed by GitHub
parent f259d60aa3
commit de78b0f4a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 12 deletions

View file

@ -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.800.qualifier Bundle-Version: 8.8.900.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

View file

@ -127,12 +127,20 @@ public abstract class CoreBuildLaunchConfigDelegate extends LaunchConfigurationT
} }
/** /**
* Returns the full path to the binary.
*
* @since 8.8 * @since 8.8
* @param configuration
* @param buildConfig
* @return
* @throws CoreException
*/ */
protected String getProgramPath(ILaunchConfiguration configuration, IBinary exeFile) throws CoreException { protected String getProgramPath(ILaunchConfiguration configuration, ICBuildConfiguration buildConfig)
throws CoreException {
String programName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); //$NON-NLS-1$ String programName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); //$NON-NLS-1$
if (programName.isBlank()) { if (programName.isBlank()) {
IBinary exeFile = getBinary(buildConfig);
return Paths.get(exeFile.getLocationURI()).toString(); return Paths.get(exeFile.getLocationURI()).toString();
} else { } else {
IPath path = new Path( IPath path = new Path(
@ -172,8 +180,9 @@ public abstract class CoreBuildLaunchConfigDelegate extends LaunchConfigurationT
// CDT launch configuration "Use workspace settings" is not selected. // CDT launch configuration "Use workspace settings" is not selected.
// The workspace setting is already considered in org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(), // The workspace setting is already considered in org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(),
// before the settings in the CDT launch configuration. // before the settings in the CDT launch configuration.
int autoBuild = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, 2); int autoBuild = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
if (autoBuild == 0) { ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING);
if (autoBuild == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED) {
return false; return false;
} }

View file

@ -19,13 +19,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.build.ICBuildConfiguration; import org.eclipse.cdt.core.build.ICBuildConfiguration;
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.debug.core.launch.CoreBuildLaunchConfigDelegate; import org.eclipse.cdt.debug.core.launch.CoreBuildLaunchConfigDelegate;
import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages; import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages;
import org.eclipse.cdt.utils.CommandLineUtil; import org.eclipse.cdt.utils.CommandLineUtil;
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.Status; import org.eclipse.core.runtime.Status;
@ -44,7 +44,7 @@ public class CoreBuildLocalRunLaunchDelegate extends CoreBuildLaunchConfigDelega
throws CoreException { throws CoreException {
ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget(); ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget();
ICBuildConfiguration buildConfig = getBuildConfiguration(configuration, mode, target, monitor); ICBuildConfiguration buildConfig = getBuildConfiguration(configuration, mode, target, monitor);
IBinary exeFile = getBinary(buildConfig); String programPath = getProgramPath(configuration, buildConfig);
try { try {
String args = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$ String args = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$
@ -54,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(getProgramPath(configuration, exeFile)); command.add(programPath);
command.addAll(Arrays.asList(arguments)); command.addAll(Arrays.asList(arguments));
ProcessBuilder builder = new ProcessBuilder(command); ProcessBuilder builder = new ProcessBuilder(command);
@ -77,7 +77,7 @@ public class CoreBuildLocalRunLaunchDelegate extends CoreBuildLaunchConfigDelega
buildConfig.setBuildEnvironment(environment); buildConfig.setBuildEnvironment(environment);
Process process = builder.start(); Process process = builder.start();
DebugPlugin.newProcess(launch, process, exeFile.getPath().lastSegment()); DebugPlugin.newProcess(launch, process, IPath.fromOSString(programPath).lastSegment());
} catch (IOException e) { } catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID,
InternalDebugCoreMessages.CoreBuildLocalRunLaunchDelegate_ErrorLaunching, e)); InternalDebugCoreMessages.CoreBuildLocalRunLaunchDelegate_ErrorLaunching, e));

View file

@ -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.400.qualifier Bundle-Version: 7.1.500.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,

View file

@ -16,7 +16,6 @@ import java.util.Properties;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import org.eclipse.cdt.core.build.ICBuildConfiguration; import org.eclipse.cdt.core.build.ICBuildConfiguration;
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;
@ -81,8 +80,7 @@ public class CoreBuildLocalDebugLaunchDelegate extends CoreBuildLaunchConfigDele
String gdbVersion = gdbLaunch.getGDBVersion(); String gdbVersion = gdbLaunch.getGDBVersion();
IBinary exeFile = getBinary(buildConfig); gdbLaunch.setProgramPath(getProgramPath(configuration, buildConfig));
gdbLaunch.setProgramPath(getProgramPath(configuration, exeFile));
gdbLaunch.setServiceFactory(new GdbDebugServicesFactory(gdbVersion, configuration)); gdbLaunch.setServiceFactory(new GdbDebugServicesFactory(gdbVersion, configuration));