Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2017-10-18 15:43:13 +0000
committerDoug Schaefer2017-10-18 16:41:40 +0000
commit416fed4d94b77d9f312fe341aa534069af8c23a2 (patch)
tree8f8a7b8b346f2dc81bfe939095eef34dc53df287
parent736d7b59550dcb1a20ab68020bd030cc4d7b086e (diff)
downloadorg.eclipse.cdt-416fed4d94b77d9f312fe341aa534069af8c23a2.tar.gz
org.eclipse.cdt-416fed4d94b77d9f312fe341aa534069af8c23a2.tar.xz
org.eclipse.cdt-416fed4d94b77d9f312fe341aa534069af8c23a2.zip
Make CMake support more resilient.
Add c++ to GCCToolChain since that's what CMake uses by default for MinGW. Synchronize the scannerInfoCache loading. Double check for toolchain files at load time for configs that don't have any. Change-Id: I8071e285ce5deb1448cabd45f394c62fe6a7f2f4
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java3
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java18
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java10
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java2
4 files changed, 23 insertions, 10 deletions
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
index 4665dda940e..1425a4f0da8 100644
--- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
@@ -474,7 +474,8 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
cppCommand = null;
if (cCommand.contains("gcc")) { //$NON-NLS-1$
cppCommand = cCommand.replace("gcc", "g++"); //$NON-NLS-1$ //$NON-NLS-2$
- commands = new String[] { cCommand, cppCommand };
+ // Also recognize c++ as an alias for g++
+ commands = new String[] { cCommand, cppCommand, cCommand.replace("gcc", "c++") }; //$NON-NLS-1$ //$NON-NLS-2$
} else if (cCommand.contains("clang")) { //$NON-NLS-1$
cppCommand = cCommand.replace("clang", "clang++"); //$NON-NLS-1$ //$NON-NLS-2$
commands = new String[] { cCommand, cppCommand };
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 0d9a9c06ac6..1308426d97d 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
@@ -58,6 +58,16 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
if (!pathStr.isEmpty()) {
Path path = Paths.get(pathStr);
toolChainFile = manager.getToolChainFile(path);
+ } else {
+ toolChainFile = manager.getToolChainFileFor(getToolChain());
+ if (toolChainFile != null) {
+ settings.put(TOOLCHAIN_FILE, toolChainFile.getPath().toString());
+ try {
+ settings.flush();
+ } catch (BackingStoreException e) {
+ Activator.log(e);
+ }
+ }
}
}
@@ -70,6 +80,10 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
super(config, name, toolChain, launchMode);
this.toolChainFile = toolChainFile;
+ saveToolChainFile();
+ }
+
+ private void saveToolChainFile() {
if (toolChainFile != null) {
Preferences settings = getSettings();
settings.put(TOOLCHAIN_FILE, toolChainFile.getPath().toString());
@@ -81,10 +95,6 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
}
}
- public ICMakeToolChainFile getToolChainFile() {
- return toolChainFile;
- }
-
@Override
public IProject[] build(int kind, Map<String, String> args, IConsole console, IProgressMonitor monitor)
throws CoreException {
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 71916f5d22a..2ffd0864ed1 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
@@ -83,10 +83,12 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
if (arch != null && !arch.isEmpty()) {
properties.put(IToolChain.ATTR_ARCH, arch);
}
- ICMakeToolChainFile file = null;
- Collection<ICMakeToolChainFile> files = manager.getToolChainFilesMatching(properties);
- if (!files.isEmpty()) {
- file = files.iterator().next();
+ ICMakeToolChainFile file = manager.getToolChainFileFor(toolChain);
+ if (file == null) {
+ Collection<ICMakeToolChainFile> files = manager.getToolChainFilesMatching(properties);
+ if (!files.isEmpty()) {
+ file = files.iterator().next();
+ }
}
// create config
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 c6137462782..f9222e48b46 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
@@ -554,7 +554,7 @@ public abstract class CBuildConfiguration extends PlatformObject
/**
* @since 6.1
*/
- protected void loadScannerInfoCache() {
+ protected synchronized void loadScannerInfoCache() {
if (scannerInfoCache == null) {
File cacheFile = getScannerInfoCacheFile();
if (cacheFile.exists()) {

Back to the top