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

Wrong active build configuration for Core Build projects. (#380)

Wrong active build configuration for Core Build projects.

The CoreBuildLaunchBar tracker always made a non default build
configuration the active build configuration. In other words, it
always made the debug build configuration active.
This caused wrong build flags if a non core build launch configuration
was used to launch a core build project binary.

Fixed the CoreBuildLaunchBar tracker to set the build configuration
to active that matches the launchBar mode.

Fixes #378
This commit is contained in:
ewaterlander 2023-04-28 13:05:54 +02:00 committed by GitHub
parent 3e47705d94
commit 9710f17847
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 6 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.debug.core; singleton:=true
Bundle-Version: 8.8.0.qualifier
Bundle-Version: 8.8.100.qualifier
Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin

View file

@ -100,6 +100,7 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener, ILaunchTar
}
if (project == null || !configManager.supports(project)) {
// The project is not a Core Build project.
return;
}
@ -109,7 +110,24 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener, ILaunchTar
lastDescriptor = descriptor;
lastTarget = target;
// Pick build config based on toolchain for target
/*
* Core build projects do not work with the concept of active build
* configurations, like managed build projects. Instead they rely
* on the launch mode and launch target set in the launchBar. A core
* build launch configuration looks at the launchBar launch mode
* and then the set of toolchains associated with the launch target
* to pick the build configuration. Core build projects still have an
* active build configuration, but it is hidden for the user and ignored for
* launching.
*
* Core build launch configurations have no options to set, so it is
* possible that users will use non core build launch configurations to
* launch a core build project binary. Non core build launch
* configurations typically launch the active build configuration. The
* active build configuration needs to match the launchBar launch mode.
*/
// Pick core build config based on launch mode and toolchain for target
// Since this may create a new config, need to run it in a Job
Job job = new Job(InternalDebugCoreMessages.CoreBuildLaunchBarTracker_Job) {
@Override
@ -120,11 +138,12 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener, ILaunchTar
Collection<IToolChain> tcs = toolChainManager.getToolChainsMatching(properties);
ICBuildConfiguration buildConfig = null;
if (!tcs.isEmpty()) {
// First, see if any existing non default build configs match the target properties
configs: for (IBuildConfiguration config : finalProject.getBuildConfigs()) {
if (!config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) {
ICBuildConfiguration testConfig = configManager.getBuildConfiguration(config);
if (testConfig != null && !(testConfig instanceof ErrorBuildConfiguration)) {
ICBuildConfiguration testConfig = configManager.getBuildConfiguration(config);
if (testConfig != null && !(testConfig instanceof ErrorBuildConfiguration)) {
// Match launch mode run/debug.
if (testConfig.getLaunchMode().equals(lastMode.getIdentifier())) {
// Match toolchain.
for (IToolChain tc : tcs) {
if (testConfig.getToolChain().equals(tc)) {
buildConfig = testConfig;