Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Sennikovsky2005-07-07 14:39:57 -0400
committerMikhail Sennikovsky2005-07-07 14:39:57 -0400
commitf4b1edba07f510db1c010c58473034b5a0feb22c (patch)
tree9cfa1029117215ced831e3da0b3b176dd64f5f21
parent5712651d444cc799a36c35cda1d364186c4e35d4 (diff)
downloadorg.eclipse.cdt-f4b1edba07f510db1c010c58473034b5a0feb22c.tar.gz
org.eclipse.cdt-f4b1edba07f510db1c010c58473034b5a0feb22c.tar.xz
org.eclipse.cdt-f4b1edba07f510db1c010c58473034b5a0feb22c.zip
CygwinPathResolver now detects whether mingw or cygwin version of gcc is used and treats include paths stored in CPATH, etc. env variables depending on that. For mingw env variable values are treated as the list of windows-style paths, while for cygwin values are treated as the list of cygwin-style paths
-rw-r--r--build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java37
1 files changed, 33 insertions, 4 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java
index e87f6efe6f..2795e470ef 100644
--- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java
+++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java
@@ -21,6 +21,8 @@ import java.util.ArrayList;
import org.eclipse.cdt.managedbuilder.core.IBuildPathResolver;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.gnu.ui.GnuUIPlugin;
import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.eclipse.core.runtime.IPath;
@@ -48,6 +50,9 @@ public class CygwinPathResolver implements IBuildPathResolver {
static final String ROOTPATTERN = "/"; //$NON-NLS-1$
static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
static final String DELIMITER_WIN = ";"; //$NON-NLS-1$
+ static final String GCC_VERSION_CMD = "gcc --version"; //$NON-NLS-1$
+ static final String MINGW_SPECIAL = "mingw "; //$NON-NLS-1$
+ static final String CYGWIN_SPECIAL = "cygwin "; //$NON-NLS-1$
static boolean checked = false;
static String binCygwin = null;
@@ -60,6 +65,10 @@ public class CygwinPathResolver implements IBuildPathResolver {
public String[] resolveBuildPaths(int pathType, String variableName,
String variableValue, IConfiguration configuration) {
+ if(isMinGW(configuration)){
+ return variableValue.split(DELIMITER_WIN);
+ }
+
String[] result = variableValue.split(DELIMITER_UNIX);
if (!isWindows()) return result;
String exePath = getBinPath();
@@ -69,7 +78,7 @@ public class CygwinPathResolver implements IBuildPathResolver {
ArrayList ls = new ArrayList();
String s = exePath + TOOL + variableValue;
- String[] lines = exec(s);
+ String[] lines = exec(s, configuration);
if (lines != null && lines.length > 0) {
result = lines[0].replace(BS,SLASH).split(DELIMITER_WIN);
}
@@ -175,10 +184,18 @@ public class CygwinPathResolver implements IBuildPathResolver {
return null;
}
- private static String[] exec(String cmd) {
+ private static String[] exec(String cmd, IConfiguration cfg) {
try {
// Process proc = Runtime.getRuntime().exec(cmd);
- Process proc = ProcessFactory.getFactory().exec(cmd.split(SP));
+ IBuildEnvironmentVariable vars[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true,true);
+ String env[] = new String[vars.length];
+ for(int i = 0; i < env.length; i++){
+ env[i] = vars[i].getName() + "=";
+ String value = vars[i].getValue();
+ if(value != null)
+ env[i] += value;
+ }
+ Process proc = ProcessFactory.getFactory().exec(cmd.split(SP), env);
if (proc != null) {
InputStream ein = proc.getInputStream();
@@ -196,5 +213,17 @@ public class CygwinPathResolver implements IBuildPathResolver {
}
return null;
}
-}
+ public static boolean isMinGW(IConfiguration cfg){
+ String versionInfo[] = exec(GCC_VERSION_CMD, cfg);
+ if(versionInfo != null) {
+ for(int i = 0; i < versionInfo.length; i++){
+ if(versionInfo[i].indexOf(MINGW_SPECIAL) != -1)
+ return true;
+ else if(versionInfo[i].indexOf(CYGWIN_SPECIAL) != -1)
+ return false;
+ }
+ }
+ return false;
+ }
+}

Back to the top