Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2007-08-09 01:55:49 +0000
committerDoug Schaefer2007-08-09 01:55:49 +0000
commit6d2009968ea57fb04874ad68f5b97e8dc3c8721c (patch)
tree7d2586f1f5a508e1146b8c9da2a477378bae4515 /build/org.eclipse.cdt.managedbuilder.gnu.ui/src
parentee3108360d7768bd174384d67b6cebd0befc8327 (diff)
downloadorg.eclipse.cdt-6d2009968ea57fb04874ad68f5b97e8dc3c8721c.tar.gz
org.eclipse.cdt-6d2009968ea57fb04874ad68f5b97e8dc3c8721c.tar.xz
org.eclipse.cdt-6d2009968ea57fb04874ad68f5b97e8dc3c8721c.zip
Added support for MinGW to be a sibling of the install directory.
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.gnu.ui/src')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java63
1 files changed, 41 insertions, 22 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 4d97392d6dc..dde8d8b1752 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,13 +11,13 @@
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;
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;
/**
@@ -55,35 +55,52 @@ public class MingwEnvironmentVariableSupplier implements
}
}
- private final IBuildEnvironmentVariable path;
+ private IBuildEnvironmentVariable path;
- public MingwEnvironmentVariableSupplier() {
+ public static IPath getBinDir() {
+ IPath subPath = new Path("mingw\\bin");
// 1. Try the mingw directory in the platform install directory
- String bin = Platform.getInstallLocation().getURL().getFile().substring(1) + "mingw/bin";
+ IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile());
+ IPath binPath = installPath.append(subPath);
+ if (binPath.toFile().isDirectory())
+ return binPath;
+
+ // 2. Try the directory above the install dir
+ binPath = installPath.removeLastSegments(1).append(subPath);
+ if (binPath.toFile().isDirectory())
+ return binPath;
- if (!new File(bin).exists()) {
- // 2. Try looking if the mingw installer ran
- bin = WindowsRegistry.getRegistry().getLocalMachineValue(
+ // 3. Try looking if the mingw installer ran
+ String mingwPath = 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";
- }
+ if (mingwPath != null) {
+ binPath = new Path(mingwPath).append("bin");
+ if (binPath.toFile().isDirectory())
+ return binPath;
}
-
- path = new MingwBuildEnvironmentVariable(
- "PATH",
- bin,
- IBuildEnvironmentVariable.ENVVAR_PREPEND);
+
+ // 4. Try the default MinGW install dir
+ binPath = new Path("C:\\MinGW\\bin");
+ if (binPath.toFile().isDirectory())
+ return binPath;
+
+ // No dice, return null
+ return null;
+ }
+
+ public MingwEnvironmentVariableSupplier() {
+ IPath binPath = getBinDir();
+ if (binPath != null)
+ path = new MingwBuildEnvironmentVariable(
+ "PATH",
+ binPath.toOSString(),
+ IBuildEnvironmentVariable.ENVVAR_PREPEND);
}
public IBuildEnvironmentVariable getVariable(String variableName,
IConfiguration configuration, IEnvironmentVariableProvider provider) {
- if (variableName.equals(path.getName()))
+ if (path != null && variableName.equals(path.getName()))
return path;
else
return null;
@@ -91,7 +108,9 @@ public class MingwEnvironmentVariableSupplier implements
public IBuildEnvironmentVariable[] getVariables(
IConfiguration configuration, IEnvironmentVariableProvider provider) {
- return new IBuildEnvironmentVariable[] { path };
+ return path != null
+ ? new IBuildEnvironmentVariable[] { path }
+ : new IBuildEnvironmentVariable[0];
}
}

Back to the top