Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2019-05-15 20:41:14 -0400
committerJeff Johnston2019-05-15 20:41:14 -0400
commit86bfd4de7e477f0423585be531bef9a53f32aa6c (patch)
tree184afc72f8ec39e2e65518e6baba92e86a586a16
parent949dd8a45f3758794707109bfddc6069c1ec3f98 (diff)
downloadorg.eclipse.cdt-86bfd4de7e477f0423585be531bef9a53f32aa6c.tar.gz
org.eclipse.cdt-86bfd4de7e477f0423585be531bef9a53f32aa6c.tar.xz
org.eclipse.cdt-86bfd4de7e477f0423585be531bef9a53f32aa6c.zip
Bug 547174 - Clean core project doesn't always show active in console
- order build config names so when clean for a project goes through the build configs, it finds the active one last and thus it will appear in the CDT build console - do this in CoreBuildLaunchbarTracker.setActiveBuildConfig() - do this in CBuildConfiguration.setActive() - do this in CoreBuildLaunchConfigDelegate.buildForLaunch() Change-Id: I379d6c9ba298f02cbc75d16e9941527cd2f9f45c
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java14
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java25
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchConfigDelegate.java15
3 files changed, 50 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
index 723ced6db4..1a508884f1 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
@@ -29,9 +29,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -284,6 +286,18 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu
CoreModel m = CoreModel.getDefault();
synchronized (m) {
IProjectDescription projectDesc = project.getDescription();
+ IBuildConfiguration[] bconfigs = project.getBuildConfigs();
+ Set<String> names = new LinkedHashSet<>();
+ for (IBuildConfiguration bconfig : bconfigs) {
+ names.add(bconfig.getName());
+ }
+ // must add default config name as it may not be in build config list
+ names.add(IBuildConfiguration.DEFAULT_CONFIG_NAME);
+ // ensure active config is last in list so clean build will clean
+ // active config last and this will be left in build console for user to see
+ names.remove(config.getName());
+ names.add(config.getName());
+
projectDesc.setActiveBuildConfig(config.getName());
project.setDescription(projectDesc, monitor);
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java
index 99791dc246..bfa49df989 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java
@@ -12,13 +12,16 @@ package org.eclipse.cdt.debug.core.launch;
import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedHashSet;
import java.util.Map;
+import java.util.Set;
import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.build.ICBuildConfiguration2;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager;
+import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages;
@@ -129,10 +132,24 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener {
if (buildConfig != null
&& !buildConfig.getBuildConfiguration().equals(finalProject.getActiveBuildConfig())) {
- // set it as active
- IProjectDescription desc = finalProject.getDescription();
- desc.setActiveBuildConfig(buildConfig.getBuildConfiguration().getName());
- finalProject.setDescription(desc, monitor);
+ CoreModel m = CoreModel.getDefault();
+ synchronized (m) {
+ // set it as active
+ IProjectDescription desc = finalProject.getDescription();
+ IBuildConfiguration[] configs = finalProject.getBuildConfigs();
+ Set<String> names = new LinkedHashSet<>();
+ for (IBuildConfiguration config : configs) {
+ names.add(config.getName());
+ }
+ // must add default config name as it may not be in build config list
+ names.add(IBuildConfiguration.DEFAULT_CONFIG_NAME);
+ // ensure active config is last in list so clean build will clean
+ // active config last and this will be left in build console for user to see
+ names.remove(buildConfig.getBuildConfiguration().getName());
+ names.add(buildConfig.getBuildConfiguration().getName());
+ desc.setActiveBuildConfig(buildConfig.getBuildConfiguration().getName());
+ finalProject.setDescription(desc, monitor);
+ }
// notify the active build config that it is active
((ICBuildConfiguration2) buildConfig).setActive();
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchConfigDelegate.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchConfigDelegate.java
index 200faa6db4..e255f80cb4 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchConfigDelegate.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchConfigDelegate.java
@@ -12,7 +12,9 @@ package org.eclipse.cdt.debug.core.launch;
import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedHashSet;
import java.util.Map;
+import java.util.Set;
import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
@@ -22,6 +24,7 @@ import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages;
+import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
@@ -143,6 +146,18 @@ public abstract class CoreBuildLaunchConfigDelegate extends LaunchConfigurationT
CoreModel m = CoreModel.getDefault();
synchronized (m) {
IProjectDescription desc = project.getDescription();
+ IBuildConfiguration[] bconfigs = project.getBuildConfigs();
+ Set<String> names = new LinkedHashSet<>();
+ for (IBuildConfiguration bconfig : bconfigs) {
+ names.add(bconfig.getName());
+ }
+ // must add default config name as it may not be in build config list
+ names.add(IBuildConfiguration.DEFAULT_CONFIG_NAME);
+ // ensure active config is last in list so clean build will clean
+ // active config last and this will be left in build console for user to see
+ names.remove(buildConfig.getBuildConfiguration().getName());
+ names.add(buildConfig.getBuildConfiguration().getName());
+
desc.setActiveBuildConfig(buildConfig.getBuildConfiguration().getName());
project.setDescription(desc, monitor);
}

Back to the top