diff options
author | Thomas Corbat | 2019-06-27 11:56:12 +0000 |
---|---|---|
committer | Thomas Corbat | 2019-06-28 06:15:49 +0000 |
commit | acb5ab5105f5d8cc13f1d7ee96a05c1b10d25b5d (patch) | |
tree | 1447158fda1d56418219e4e79aa6357dfa351b66 | |
parent | 9dd503800cbfec765cf0a02d8475acf3e7ff7200 (diff) | |
download | org.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>
-rw-r--r-- | core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java | 28 |
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 c92a8f329b0..6ac686ba6f0 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); } |