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

Bug 333587 - Update to handle new MinGW installer.

This commit is contained in:
Doug Schaefer 2011-01-05 18:30:02 +00:00
parent e27e34dd13
commit 67cb94a163

View file

@ -16,7 +16,6 @@ import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier; import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider; import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.utils.PathUtil; import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.cdt.utils.WindowsRegistry;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
@ -63,66 +62,61 @@ public class MingwEnvironmentVariableSupplier implements
private IBuildEnvironmentVariable path; private IBuildEnvironmentVariable path;
public static IPath getBinDir() { public static IPath getBinDir() {
if (!checked) if (!checked) {
findBinDir(); binDir = findBinDir();
checked = true;
}
return binDir; return binDir;
} }
private static void findBinDir() { private static IPath findBinDir() {
// 1. Try the mingw directory in the platform install directory // Try in MinGW home
String mingwHome = System.getenv("MINGW_HOME"); //$NON-NLS-1$
IPath mingwBinDir = new Path(mingwHome + "\\bin"); //$NON-NLS-1$
if (mingwBinDir.toFile().isDirectory())
return mingwBinDir;
// Try the mingw directory in the platform install directory
// CDT distributions like Wascana may distribute MinGW like that // CDT distributions like Wascana may distribute MinGW like that
IPath subPath = new Path("mingw\\bin"); //$NON-NLS-1$
IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile()); IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile());
IPath binPathTemp = installPath.append(subPath); mingwBinDir = installPath.append("mingw\\bin"); //$NON-NLS-1$
if (binPathTemp.toFile().isDirectory()) if (mingwBinDir.toFile().isDirectory())
binDir = binPathTemp; return mingwBinDir;
// Look in PATH values. Look for mingw32-gcc.exe
// TODO: Since this dir is already in the PATH, why are we adding it here?
// This is really only to support isToolchainAvail. Must be a better way.
IPath gccLoc = PathUtil.findProgramLocation("mingw32-gcc.exe"); //$NON-NLS-1$
if (gccLoc != null)
return gccLoc.removeLastSegments(1);
// 2. Try the directory above the install dir (another possible distribution) // Try the default MinGW install dir
if (binDir == null) { mingwBinDir = new Path("C:\\MinGW\\bin"); //$NON-NLS-1$
binPathTemp = installPath.removeLastSegments(1).append(subPath); if (mingwBinDir.toFile().isDirectory())
if (binPathTemp.toFile().isDirectory()) { return mingwBinDir;
binDir = binPathTemp;
}
}
// 3. Look in PATH values. Look for mingw32-gcc.exe return null;
if (binDir == null) {
IPath location = PathUtil.findProgramLocation("mingw32-gcc.exe"); //$NON-NLS-1$
if (location!=null) {
binDir = location.removeLastSegments(1);
}
}
// 4. Try looking if the mingw installer ran
if (binDir == null) {
WindowsRegistry registry = WindowsRegistry.getRegistry();
if (registry != null) {
String mingwPath = registry.getLocalMachineValue(
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MinGW", //$NON-NLS-1$
"InstallLocation"); //$NON-NLS-1$
if (mingwPath != null) {
binPathTemp = new Path(mingwPath).append("bin"); //$NON-NLS-1$
if (binPathTemp.toFile().isDirectory())
binDir = binPathTemp;
}
}
}
// 5. Try the default MinGW install dir
if (binDir == null) {
binPathTemp = new Path("C:\\MinGW\\bin"); //$NON-NLS-1$
if (binPathTemp.toFile().isDirectory())
binDir = binPathTemp;
}
checked = true;
} }
public static IPath getMsysBinDir() { public static IPath getMsysBinDir() {
// Just look in the install location parent dir // Just look in the install location parent dir
IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile()); IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile());
IPath msysBinPath = installPath.append("msys\\bin"); //$NON-NLS-1$ IPath msysBinPath = installPath.append("msys\\bin"); //$NON-NLS-1$
return msysBinPath.toFile().isDirectory() ? msysBinPath : null; if (msysBinPath.toFile().isDirectory())
return msysBinPath;
String mingwHome = System.getenv("MINGW_HOME"); //$NON-NLS-1$
if (mingwHome != null) {
msysBinPath = new Path(mingwHome + "\\msys\\1.0\\bin"); //$NON-NLS-1$
if (msysBinPath.toFile().isDirectory())
return msysBinPath;
}
// Try the new MinGW msys bin dir
msysBinPath = new Path("C:\\MinGW\\msys\\1.0\\bin"); //$NON-NLS-1$
if (msysBinPath.toFile().isDirectory())
return msysBinPath;
return null;
} }
public MingwEnvironmentVariableSupplier() { public MingwEnvironmentVariableSupplier() {