1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-03-28 14:56:28 +01:00

Launchbar build button always starts a build. (#812)

Fixed the problem that the LaunchBar build button was not working when
auto build was disabled in the launch configuration.

Fixes #765
This commit is contained in:
ewaterlander 2024-09-12 23:16:25 +02:00 committed by GitHub
parent efbba15eab
commit 19a809d3e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 3 deletions

View file

@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.ui.ide,
org.eclipse.debug.ui,
org.eclipse.launchbar.core
org.eclipse.launchbar.core,
org.eclipse.cdt.debug.core;bundle-version="8.8.400"
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin

View file

@ -18,6 +18,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
@ -33,6 +34,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchDelegate;
import org.eclipse.debug.core.ILaunchMode;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
@ -100,6 +102,12 @@ public class BuildActiveCommandHandler extends AbstractHandler {
if (delegate == null)
delegate = config.getType().getDelegates(modes)[0];
ILaunchConfigurationDelegate configDel = delegate.getDelegate();
/* This build is started manually by pressing the LaunchBar build button.
* Always build, regardless if auto build is disabled in the launch configuration.
*/
ILaunchConfigurationWorkingCopy configCopy = config.copy(config.getName() + "Copy"); //$NON-NLS-1$
configCopy.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED);
if (configDel instanceof ILaunchConfigurationTargetedDelegate) {
ILaunchConfigurationTargetedDelegate configDel2 = (ILaunchConfigurationTargetedDelegate) configDel;
boolean ret;
@ -107,7 +115,7 @@ public class BuildActiveCommandHandler extends AbstractHandler {
if (!ret) {
return Status.CANCEL_STATUS;
}
if (!configDel2.buildForLaunch(config, mode, target, monitor)) {
if (!configDel2.buildForLaunch(configCopy, mode, target, monitor)) {
return Status.OK_STATUS;
}
} else if (configDel instanceof ILaunchConfigurationDelegate2) {
@ -117,7 +125,8 @@ public class BuildActiveCommandHandler extends AbstractHandler {
if (!ret) {
return Status.CANCEL_STATUS;
}
if (!configDel2.buildForLaunch(config, mode, monitor)) {
if (!configDel2.buildForLaunch(configCopy, mode, monitor)) {
return Status.OK_STATUS;
}
}