1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

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
This commit is contained in:
Doug Schaefer 2017-10-18 11:43:13 -04:00
parent 736d7b5955
commit 416fed4d94
4 changed files with 23 additions and 10 deletions

View file

@ -474,7 +474,8 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
cppCommand = null; cppCommand = null;
if (cCommand.contains("gcc")) { //$NON-NLS-1$ if (cCommand.contains("gcc")) { //$NON-NLS-1$
cppCommand = cCommand.replace("gcc", "g++"); //$NON-NLS-1$ //$NON-NLS-2$ 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$ } else if (cCommand.contains("clang")) { //$NON-NLS-1$
cppCommand = cCommand.replace("clang", "clang++"); //$NON-NLS-1$ //$NON-NLS-2$ cppCommand = cCommand.replace("clang", "clang++"); //$NON-NLS-1$ //$NON-NLS-2$
commands = new String[] { cCommand, cppCommand }; commands = new String[] { cCommand, cppCommand };

View file

@ -58,6 +58,16 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
if (!pathStr.isEmpty()) { if (!pathStr.isEmpty()) {
Path path = Paths.get(pathStr); Path path = Paths.get(pathStr);
toolChainFile = manager.getToolChainFile(path); 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); super(config, name, toolChain, launchMode);
this.toolChainFile = toolChainFile; this.toolChainFile = toolChainFile;
saveToolChainFile();
}
private void saveToolChainFile() {
if (toolChainFile != null) { if (toolChainFile != null) {
Preferences settings = getSettings(); Preferences settings = getSettings();
settings.put(TOOLCHAIN_FILE, toolChainFile.getPath().toString()); settings.put(TOOLCHAIN_FILE, toolChainFile.getPath().toString());
@ -81,10 +95,6 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
} }
} }
public ICMakeToolChainFile getToolChainFile() {
return toolChainFile;
}
@Override @Override
public IProject[] build(int kind, Map<String, String> args, IConsole console, IProgressMonitor monitor) public IProject[] build(int kind, Map<String, String> args, IConsole console, IProgressMonitor monitor)
throws CoreException { throws CoreException {

View file

@ -83,10 +83,12 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
if (arch != null && !arch.isEmpty()) { if (arch != null && !arch.isEmpty()) {
properties.put(IToolChain.ATTR_ARCH, arch); properties.put(IToolChain.ATTR_ARCH, arch);
} }
ICMakeToolChainFile file = null; ICMakeToolChainFile file = manager.getToolChainFileFor(toolChain);
Collection<ICMakeToolChainFile> files = manager.getToolChainFilesMatching(properties); if (file == null) {
if (!files.isEmpty()) { Collection<ICMakeToolChainFile> files = manager.getToolChainFilesMatching(properties);
file = files.iterator().next(); if (!files.isEmpty()) {
file = files.iterator().next();
}
} }
// create config // create config

View file

@ -554,7 +554,7 @@ public abstract class CBuildConfiguration extends PlatformObject
/** /**
* @since 6.1 * @since 6.1
*/ */
protected void loadScannerInfoCache() { protected synchronized void loadScannerInfoCache() {
if (scannerInfoCache == null) { if (scannerInfoCache == null) {
File cacheFile = getScannerInfoCacheFile(); File cacheFile = getScannerInfoCacheFile();
if (cacheFile.exists()) { if (cacheFile.exists()) {