From 049d28c3fe6d0df26d5fc5d4fba574f1f8c3c82a Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Thu, 22 Feb 2007 20:51:27 +0000 Subject: Removed hardcoding of MinGW location. --- .../mingw/MingwEnvironmentVariableSupplier.java | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'build/org.eclipse.cdt.managedbuilder.gnu.ui/src') 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 ce0cd9ff9e8..e04899b9a4e 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 @@ -11,6 +11,8 @@ package org.eclipse.cdt.managedbuilder.gnu.mingw; +import java.io.File; + import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier; @@ -56,13 +58,22 @@ public class MingwEnvironmentVariableSupplier implements private final IBuildEnvironmentVariable path; public MingwEnvironmentVariableSupplier() { - String bin = "C:/MinGW/bin"; + // 1. Try the mingw directory in the platform install directory + String bin = Platform.getInstallLocation().getURL().getFile().substring(1) + "mingw/bin"; - // TODO try finding MinGW in either of: - // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW, InstallLocation - // or using: - // String bin = Platform.getInstallLocation().getURL().getFile().substring(1) - // + "mingw/bin"; + if (!new File(bin).exists()) { + // 2. Try looking if the mingw installer ran + bin = WindowsRegistry.getRegistry().getLocalMachineValue( + "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MinGW", + "InstallLocation"); + if (bin != null) + bin += "\\bin"; + + if (bin == null || !new File(bin).exists()) { + // 3. Try the standard location + bin = "C:/MinGW/bin"; + } + } path = new MingwBuildEnvironmentVariable( "PATH", -- cgit v1.2.1