Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2018-02-02 20:38:23 +0000
committerDoug Schaefer2018-02-13 15:03:45 +0000
commit10aaaca50814d2bb6e8301ed12057675a3e5fb00 (patch)
treeddd167cca48bcf8ce2fc253007c0c9e8779ed7b1
parent97ce0ef991fbe207dbe7a073c4c34187e9fd0b1d (diff)
downloadorg.eclipse.cdt-10aaaca50814d2bb6e8301ed12057675a3e5fb00.tar.gz
org.eclipse.cdt-10aaaca50814d2bb6e8301ed12057675a3e5fb00.tar.xz
org.eclipse.cdt-10aaaca50814d2bb6e8301ed12057675a3e5fb00.zip
Bug 530673 Fix issue with CMake and changing toolchains.
Cleaned up add and remove of toolchain files, handling of when a toolchain changes for a config, and the launch bar tracker to be more accurate with toolchains. Change-Id: I1a1efdf08a5f47058552c85404fe8d602d158e73 (cherry picked from commit 5b29b5b5d8714a82b9d9667c7e61d44a554bec76)
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java4
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java18
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/messages.properties2
-rw-r--r--build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java24
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java33
5 files changed, 63 insertions, 18 deletions
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
index a666c3d68b..fbaaa6c81c 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
@@ -81,6 +81,10 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
}
}
+ public ICMakeToolChainFile getToolChainFile() {
+ return toolChainFile;
+ }
+
private void saveToolChainFile() {
Preferences settings = getSettings();
settings.put(TOOLCHAIN_FILE, toolChainFile.getPath().toString());
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java
index 2ffd0864ed..b3e6b35015 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java
@@ -37,7 +37,8 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
}
@Override
- public ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) throws CoreException {
+ public synchronized ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name)
+ throws CoreException {
if (config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) {
IToolChain toolChain = null;
@@ -66,7 +67,20 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
return null;
}
} else {
- return new CMakeBuildConfiguration(config, name);
+ CMakeBuildConfiguration cmakeConfig = new CMakeBuildConfiguration(config, name);
+ ICMakeToolChainFile tcFile = cmakeConfig.getToolChainFile();
+ IToolChain toolChain = cmakeConfig.getToolChain();
+ if (toolChain == null || tcFile == null) {
+ // config not complete?
+ return null;
+ }
+ if (!toolChain.equals(tcFile.getToolChain())) {
+ // toolchain changed
+ return new CMakeBuildConfiguration(config, name, tcFile.getToolChain(), tcFile,
+ cmakeConfig.getLaunchMode());
+ } else {
+ return cmakeConfig;
+ }
}
}
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/messages.properties b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/messages.properties
index a0aead98df..db58245796 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/messages.properties
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/messages.properties
@@ -10,6 +10,6 @@ CMakeBuildConfiguration_BuildingIn=Building in: %s\n
CMakeBuildConfiguration_BuildingComplete=Build complete: %s\n
CMakeBuildConfiguration_Cleaning=Cleaning %s
CMakeBuildConfiguration_NotFound=CMakeFiles not found. Assuming clean.
-CMakeBuildConfiguration_NoToolchainFile=No toolchain file found for this target.
+CMakeBuildConfiguration_NoToolchainFile=No CMake toolchain file found for this target.
CMakeBuildConfiguration_ProcCompCmds=Processing compile commands %s
CMakeBuildConfiguration_ProcCompJson=Processing compile_commands.json
diff --git a/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java
index 7cc58fbb99..6a6275747d 100644
--- a/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java
+++ b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java
@@ -100,11 +100,11 @@ public class CMakePreferencePage extends PreferencePage implements IWorkbenchPre
WizardDialog dialog = new WizardDialog(getShell(), wizard);
if (dialog.open() == Window.OK) {
ICMakeToolChainFile file = wizard.getNewFile();
- if (filesToRemove.containsKey(file.getPath())) {
- filesToRemove.remove(file.getPath());
- } else {
- filesToAdd.put(file.getPath(), file);
+ ICMakeToolChainFile oldFile = manager.getToolChainFile(file.getPath());
+ if (oldFile != null) {
+ filesToRemove.put(oldFile.getPath(), oldFile);
}
+ filesToAdd.put(file.getPath(), file);
updateTable();
}
}
@@ -162,27 +162,27 @@ public class CMakePreferencePage extends PreferencePage implements IWorkbenchPre
files.put(file.getPath(), file);
}
- for (ICMakeToolChainFile file : filesToAdd.values()) {
- files.put(file.getPath(), file);
- }
-
for (ICMakeToolChainFile file : filesToRemove.values()) {
files.remove(file.getPath());
}
+ for (ICMakeToolChainFile file : filesToAdd.values()) {
+ files.put(file.getPath(), file);
+ }
+
return files;
}
@Override
public boolean performOk() {
- for (ICMakeToolChainFile file : filesToAdd.values()) {
- manager.addToolChainFile(file);
- }
-
for (ICMakeToolChainFile file : filesToRemove.values()) {
manager.removeToolChainFile(file);
}
+ for (ICMakeToolChainFile file : filesToAdd.values()) {
+ manager.addToolChainFile(file);
+ }
+
filesToAdd.clear();
filesToRemove.clear();
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 81ccf982b8..18d30b9863 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
@@ -18,6 +18,7 @@ import org.eclipse.cdt.core.build.IToolChainManager;
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.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
@@ -95,11 +96,37 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener {
properties.putAll(target.getAttributes());
Collection<IToolChain> tcs = toolChainManager.getToolChainsMatching(properties);
if (!tcs.isEmpty()) {
- IToolChain toolChain = tcs.iterator().next();
- ICBuildConfiguration buildConfig = configManager.getBuildConfiguration(finalProject, toolChain,
- mode.getIdentifier(), monitor);
+ ICBuildConfiguration buildConfig = null;
+
+ // First, see if any existing non default build configs match
+ configs: for (IBuildConfiguration config : finalProject.getBuildConfigs()) {
+ if (!config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) {
+ ICBuildConfiguration testConfig = configManager.getBuildConfiguration(config);
+ if (testConfig != null) {
+ for (IToolChain tc : tcs) {
+ if (testConfig.getToolChain().equals(tc)) {
+ buildConfig = testConfig;
+ break configs;
+ }
+ }
+ }
+ }
+ }
+
+ if (buildConfig == null) {
+ for (IToolChain tc : tcs) {
+ IToolChain toolChain = tcs.iterator().next();
+ buildConfig = configManager.getBuildConfiguration(finalProject, toolChain,
+ mode.getIdentifier(), monitor);
+ if (buildConfig != null) {
+ break;
+ }
+ }
+ }
+
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);

Back to the top