Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorThomas Corbat2019-06-27 07:56:12 -0400
committerThomas Corbat2019-06-28 02:15:49 -0400
commitacb5ab5105f5d8cc13f1d7ee96a05c1b10d25b5d (patch)
tree1447158fda1d56418219e4e79aa6357dfa351b66 /core
parent9dd503800cbfec765cf0a02d8475acf3e7ff7200 (diff)
downloadorg.eclipse.cdt-acb5ab5105f5d8cc13f1d7ee96a05c1b10d25b5d.tar.gz
org.eclipse.cdt-acb5ab5105f5d8cc13f1d7ee96a05c1b10d25b5d.tar.xz
org.eclipse.cdt-acb5ab5105f5d8cc13f1d7ee96a05c1b10d25b5d.zip
Bug 548712 - MinGW installation is not recognized
Recognize MinGW installations by checking the path of gcc.exe for substring "ming". Change-Id: Ibc6d4b03ef715036176e3aea6382dd986e4caae8 Signed-off-by: Thomas Corbat <tcorbat@hsr.ch>
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java28
1 files changed, 19 insertions, 9 deletions
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java
index c92a8f329b..6ac686ba6f 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java
@@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.core;
import java.io.File;
import java.util.Collections;
import java.util.Map;
+import java.util.Optional;
import java.util.WeakHashMap;
import org.eclipse.cdt.core.CCorePlugin;
@@ -150,6 +151,14 @@ public class MinGW {
return rootValue;
}
+ private static Optional<String> findMinGwInstallationLocation(String exeName, String envPath) {
+ IPath exeLocation = PathUtil.findProgramLocation(exeName, envPath);
+ if (exeLocation != null) {
+ return Optional.of(exeLocation.removeLastSegments(2).toOSString());
+ }
+ return Optional.empty();
+ }
+
private static String findMingwInPath(String envPath) {
if (envPath == null) {
// $PATH from user preferences
@@ -166,18 +175,19 @@ public class MinGW {
// Check for MinGW-w64 on Windows 64 bit, see
// http://mingw-w64.sourceforge.net/
if (Platform.ARCH_X86_64.equals(Platform.getOSArch())) {
- IPath gcc64Loc = PathUtil.findProgramLocation("x86_64-w64-mingw32-gcc.exe", envPath); //$NON-NLS-1$
- if (gcc64Loc != null) {
- mingwLocation = gcc64Loc.removeLastSegments(2).toOSString();
- }
+ mingwLocation = findMinGwInstallationLocation("x86_64-w64-mingw32-gcc.exe", envPath).orElse(null); //$NON-NLS-1$
}
- // Look for mingw32-gcc.exe
if (mingwLocation == null) {
- IPath gccLoc = PathUtil.findProgramLocation("mingw32-gcc.exe", envPath); //$NON-NLS-1$
- if (gccLoc != null) {
- mingwLocation = gccLoc.removeLastSegments(2).toOSString();
- }
+ mingwLocation = findMinGwInstallationLocation("mingw32-gcc.exe", envPath).orElse(null); //$NON-NLS-1$
+ }
+
+ // Fallback: Look for paths containing "mingw"
+ if (mingwLocation == null) {
+ mingwLocation = findMinGwInstallationLocation("gcc.exe", envPath) //$NON-NLS-1$
+ .filter(path -> path.toLowerCase().contains("mingw")) //$NON-NLS-1$
+ .orElse(null);
+
}
mingwLocationCache.put(envPath, mingwLocation);
}

Back to the top