1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Fixes to remove duplicates and invalid CMake toolchain entries.

Change-Id: I1a8212945428b00d332b9f78c5a3eb81091f3fe6
This commit is contained in:
Doug Schaefer 2016-10-17 21:59:41 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent 47784c8980
commit 5540c75ce0

View file

@ -7,6 +7,7 @@
*******************************************************************************/
package org.eclipse.cdt.cmake.core.internal;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
@ -54,15 +55,21 @@ public class CMakeToolChainManager implements ICMakeToolChainManager {
try {
for (String childName : prefs.childrenNames()) {
Preferences tcNode = prefs.node(childName);
String path = tcNode.get(PATH, "/"); //$NON-NLS-1$
ICMakeToolChainFile file = new CMakeToolChainFile(childName, Paths.get(path));
for (String key : tcNode.keys()) {
String value = tcNode.get(key, ""); //$NON-NLS-1$
if (!value.isEmpty()) {
file.setProperty(key, value);
String pathStr = tcNode.get(PATH, "/"); //$NON-NLS-1$
Path path = Paths.get(pathStr);
if (Files.exists(path) && !files.containsKey(path)) {
ICMakeToolChainFile file = new CMakeToolChainFile(childName, path);
for (String key : tcNode.keys()) {
String value = tcNode.get(key, ""); //$NON-NLS-1$
if (!value.isEmpty()) {
file.setProperty(key, value);
}
}
files.put(path, file);
} else {
tcNode.removeNode();
prefs.flush();
}
files.put(file.getPath(), file);
}
} catch (BackingStoreException e) {
Activator.log(e);
@ -93,6 +100,9 @@ public class CMakeToolChainManager implements ICMakeToolChainManager {
@Override
public void addToolChainFile(ICMakeToolChainFile file) {
init();
if (files.containsKey(file.getPath())) {
removeToolChainFile(file);
}
files.put(file.getPath(), file);
// save it