Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2018-02-13 21:33:10 +0000
committerJeff Johnston2018-02-16 23:01:58 +0000
commit13ecd568b3a1da85d6731cf6934e0c81acf4e9bc (patch)
treecbed09be8fc4d3c92e7ffd431924602927cb92f9
parent03e190164eeff26b301a5b9dce811eabcc33f18b (diff)
downloadorg.eclipse.cdt-13ecd568b3a1da85d6731cf6934e0c81acf4e9bc.tar.gz
org.eclipse.cdt-13ecd568b3a1da85d6731cf6934e0c81acf4e9bc.tar.xz
org.eclipse.cdt-13ecd568b3a1da85d6731cf6934e0c81acf4e9bc.zip
Bug 531125 - Tupled gcc toolchains should not be the local default
- change ToolChainManager so that when creating the types map for the first time, make it a LinkedHashMap instead of HashMap so order of input is preserved (first in = first out) - fix GCCPathToolChainProvider so that it adds non-tupled gcc to the ToolChainManger before adding any tupled version Change-Id: I84602a98dd4949a2f9847d4e72c428cdedd60688
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java23
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java3
2 files changed, 21 insertions, 5 deletions
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java
index dae4f2df0d..7debdd9039 100644
--- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java
@@ -9,6 +9,8 @@ package org.eclipse.cdt.build.gcc.core.internal;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -29,7 +31,8 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
public static final String ID = "org.eclipse.cdt.build.gcc.core.gccPathProvider"; //$NON-NLS-1$
- private static final Pattern gccPattern = Pattern.compile("(.*-)?gcc(\\.exe)?"); //$NON-NLS-1$
+ private static final Pattern gccPattern = Pattern.compile("gcc(\\.exe)?"); //$NON-NLS-1$
+ private static final Pattern tupledGccPattern = Pattern.compile("(.*-)?gcc(\\.exe)?"); //$NON-NLS-1$
private static final Pattern clangPattern = Pattern.compile("clang(\\.exe)?"); //$NON-NLS-1$
@Override
@@ -40,6 +43,7 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
@Override
public void init(IToolChainManager manager) {
String path = System.getenv("PATH"); //$NON-NLS-1$
+ List<IToolChain> tupledList = new ArrayList<>();
for (String dirStr : path.split(File.pathSeparator)) {
File dir = new File(dirStr);
if (dir.isDirectory()) {
@@ -48,7 +52,8 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
continue;
}
Matcher matcher = gccPattern.matcher(file.getName());
- if (matcher.matches()) {
+ Matcher matcher2 = tupledGccPattern.matcher(file.getName());
+ if (matcher.matches() || matcher2.matches()) {
try {
GCCInfo info = new GCCInfo(file.toString());
if (info.target != null && info.version != null) {
@@ -71,7 +76,12 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
try {
if (manager.getToolChain(gcc.getTypeId(), gcc.getId()) == null) {
// Only add if another provider hasn't already added it
- manager.addToolChain(gcc);
+ if (matcher.matches()) {
+ manager.addToolChain(gcc);
+ } else {
+ // add to tupled list to register later
+ tupledList.add(gcc);
+ }
}
} catch (CoreException e) {
CCorePlugin.log(e.getStatus());
@@ -80,7 +90,7 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
}
} catch (IOException e) {
Activator.log(e);
- }
+ }
} else {
matcher = clangPattern.matcher(file.getName());
if (matcher.matches()) {
@@ -93,6 +103,11 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
}
}
}
+ // add tupled toolchains last so we won't find any local compiler as a tupled chain before the normal
+ // defaults (e.g. don't want to find x86_64-redhat-linux-gcc before gcc if looking for a local toolchain)
+ for (IToolChain t : tupledList) {
+ manager.addToolChain(t);
+ }
}
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java
index 9129c2d5a9..efebaa9c02 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java
@@ -11,6 +11,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -133,7 +134,7 @@ public class ToolChainManager implements IToolChainManager {
public void addToolChain(IToolChain toolChain) {
Map<String, IToolChain> type = toolChains.get(toolChain.getTypeId());
if (type == null) {
- type = new HashMap<>();
+ type = new LinkedHashMap<>(); // use LinkedHashMap so input order is maintained
toolChains.put(toolChain.getTypeId(), type);
}
type.put(toolChain.getId(), toolChain);

Back to the top