diff options
author | Doug Schaefer | 2011-01-05 18:49:57 +0000 |
---|---|---|
committer | Doug Schaefer | 2011-01-05 18:49:57 +0000 |
commit | c4548d915a8bad6d2a83ce2e65f6e1c25866a2b4 (patch) | |
tree | 254ebca66bc03da4fa2f5163bbf0eb5fa2e8ed83 | |
parent | 5403eb66bf0efd44e802a23dbb0d3f87d8e24592 (diff) | |
download | org.eclipse.cdt-c4548d915a8bad6d2a83ce2e65f6e1c25866a2b4.tar.gz org.eclipse.cdt-c4548d915a8bad6d2a83ce2e65f6e1c25866a2b4.tar.xz org.eclipse.cdt-c4548d915a8bad6d2a83ce2e65f6e1c25866a2b4.zip |
Bug 333587 - Update to work with new MinGW installer. Backported from HEAD.
-rw-r--r-- | build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java | 104 |
1 files changed, 49 insertions, 55 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java index c42d1100706..59d01778939 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java @@ -17,7 +17,6 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier; import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider; -import org.eclipse.cdt.utils.WindowsRegistry; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; @@ -64,75 +63,70 @@ public class MingwEnvironmentVariableSupplier implements private IBuildEnvironmentVariable path; public static IPath getBinDir() { - if (!checked) - findBinDir(); + if (!checked) { + binDir = findBinDir(); + checked = true; + } return binDir; } - private static void findBinDir() { - // 1. Try the mingw directory in the platform install directory + private static IPath findBinDir() { + // 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 - IPath subPath = new Path("mingw\\bin"); //$NON-NLS-1$ IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile()); - IPath binPathTemp = installPath.append(subPath); - if (binPathTemp.toFile().isDirectory()) - binDir = binPathTemp; - - // 2. Try the directory above the install dir (another possible distribution) - if (binDir == null) { - binPathTemp = installPath.removeLastSegments(1).append(subPath); - if (binPathTemp.toFile().isDirectory()) { - binDir = binPathTemp; - } - } - - // 3. Look in PATH values. Look for mingw32-gcc.exe - if (binDir == null) { - String pathVariable = System.getenv("PATH"); //$NON-NLS-1$ - String[] paths = pathVariable.split(";"); //$NON-NLS-1$ - for (String pathStr : paths) { - // If there is a trailing / or \, remove it - if ((pathStr.endsWith("\\") || pathStr.endsWith("/")) && pathStr.length() > 1) //$NON-NLS-1$ //$NON-NLS-2$ - pathStr = pathStr.substring(0, pathStr.length() - 1); - - File pathFile = new File(pathStr + "\\mingw32-gcc.exe"); //$NON-NLS-1$ - if (pathFile.exists()) { - binDir = new Path(pathStr); - break; - } - } - } - - // 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; - } + mingwBinDir = installPath.append("mingw\\bin"); //$NON-NLS-1$ + if (mingwBinDir.toFile().isDirectory()) + 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. + String pathVariable = System.getenv("PATH"); //$NON-NLS-1$ + String[] paths = pathVariable.split(";"); //$NON-NLS-1$ + for (String pathStr : paths) { + // If there is a trailing / or \, remove it + if ((pathStr.endsWith("\\") || pathStr.endsWith("/")) && pathStr.length() > 1) //$NON-NLS-1$ //$NON-NLS-2$ + pathStr = pathStr.substring(0, pathStr.length() - 1); + + File pathFile = new File(pathStr + "\\mingw32-gcc.exe"); //$NON-NLS-1$ + if (pathFile.exists()) { + return new Path(pathStr); } } - // 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; - } + // Try the default MinGW install dir + mingwBinDir = new Path("C:\\MinGW\\bin"); //$NON-NLS-1$ + if (mingwBinDir.toFile().isDirectory()) + return mingwBinDir; - checked = true; + return null; } public static IPath getMsysBinDir() { // Just look in the install location parent dir IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile()); 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() { |