Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2012-03-13 13:25:14 -0400
committerAndrew Gvozdev2012-03-13 13:25:14 -0400
commitdc01366f97a94046176447c2b7be076d72e1d3b0 (patch)
tree31cf42ee5408231e3aa4d5e1e5562358765c1944 /build/org.eclipse.cdt.managedbuilder.core
parent863ac9d61ba4066699b49a5a46a077036a26c2b6 (diff)
downloadorg.eclipse.cdt-dc01366f97a94046176447c2b7be076d72e1d3b0.tar.gz
org.eclipse.cdt-dc01366f97a94046176447c2b7be076d72e1d3b0.tar.xz
org.eclipse.cdt-dc01366f97a94046176447c2b7be076d72e1d3b0.zip
bug 364733: Internal Builder does not work with Cygwin toolchain
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java113
1 files changed, 18 insertions, 95 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java
index 356f69259a..b0a23fdb09 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
-import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
@@ -21,12 +20,14 @@ import java.util.Set;
import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.ICommandLauncher;
+import org.eclipse.cdt.internal.core.Cygwin;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildCommand;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
/**
@@ -41,56 +42,28 @@ import org.eclipse.core.runtime.SubProgressMonitor;
*/
public class CommandBuilder implements IBuildModelBuilder {
private static final String PATH_ENV = "PATH"; //$NON-NLS-1$
- private static final String PROPERTY_DELIMITER = "path.separator"; //$NON-NLS-1$
- private static final String PROPERTY_OS_NAME = "os.name"; //$NON-NLS-1$
- private static final String PROPERTY_OS_VALUE = "windows";//$NON-NLS-1$
- static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
- static final String DELIMITER_WINDOWS = ";"; //$NON-NLS-1$
+ private static final String NEWLINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
private IBuildCommand fCmd;
private Process fProcess;
private String fErrMsg;
- private static final String BUILDER_MSG_HEADER = "InternalBuilder.msg.header"; //$NON-NLS-1$
- private static final String NEWLINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
-
-/*
- * no need in this for now, Spawner is always used
- *
- protected class SpawnerfreeLauncher extends CommandLauncher{
-
- public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory) {
- try {
- // add platform specific arguments (shell invocation)
- fCommandArgs = constructCommandArray(commandPath.toOSString(), args);
- fProcess = Runtime.getRuntime().exec(fCommandArgs, env, changeToDirectory.toFile());
-// ProcessFactory.getFactory().exec(fCommandArgs, env, changeToDirectory.toFile());
- fErrorMessage = ""; //$NON-NLS-1$
- } catch (IOException e) {
- setErrorMessage(e.getMessage());
- fProcess = null;
- }
- return fProcess;
- }
- }
-*/
- /*
- * a temporary work-around to resolve the bug#145099
- * (https://bugs.eclipse.org/bugs/show_bug.cgi?id=145099)
- *
- * this will be removed after fixing the bug#145737
- * (https://bugs.eclipse.org/bugs/show_bug.cgi?id=145737)
- */
- private class CommandSearchLauncher extends CommandLauncher{
-
+ private class CommandSearchLauncher extends CommandLauncher {
@Override
protected String[] constructCommandArray(String command, String[] commandArgs) {
String[] args = new String[1 + commandArgs.length];
- if(!isWindows()){
- //find a full path to an executable
- String cmd = getExecutable(command, fCmd.getEnvironment());
- if(cmd != null)
- command = cmd;
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ // find a location of the executable
+ String envPathValue = fCmd.getEnvironment().get(PATH_ENV);
+ IPath location = PathUtil.findProgramLocation(command, envPathValue);
+ if(location != null) {
+ try {
+ // Handle cygwin link
+ command = Cygwin.cygwinToWindowsPath(location.toString(), envPathValue);
+ } catch (Exception e) {
+ command = location.toString();
+ }
+ }
//if not found, continue with the command passed as an argument
}
@@ -99,7 +72,6 @@ public class CommandBuilder implements IBuildModelBuilder {
return args;
}
-
@Override
protected void printCommandLine(OutputStream os) {
if (os != null) {
@@ -274,7 +246,7 @@ public class CommandBuilder implements IBuildModelBuilder {
protected void printMessage(String msg, OutputStream os){
if (os != null) {
- msg = ManagedMakeMessages.getFormattedString(BUILDER_MSG_HEADER, msg);
+ msg = ManagedMakeMessages.getFormattedString("InternalBuilder.msg.header", msg); //$NON-NLS-1$
printMessage(null, msg, os);
}
@@ -305,53 +277,4 @@ public class CommandBuilder implements IBuildModelBuilder {
}
return buf.toString();
}
-
- private String getExecutable(String command, Map<String, String> environment){
- if(new Path(command).isAbsolute())
- return command;
- return searchExecutable(command, getPaths(environment));
- }
-
- private String[] getPaths(Map<String, String> env){
- String pathsStr = env.get(PATH_ENV);
- if(pathsStr == null){
- Set<Entry<String, String>> entrySet = env.entrySet();
- for (Entry<String, String> entry : entrySet) {
- if(PATH_ENV.equalsIgnoreCase(entry.getKey())){
- pathsStr = entry.getValue();
- break;
- }
- }
- }
- if(pathsStr != null){
- String delimiter = getDelimiter();
-
- return pathsStr.split(delimiter);
- }
- return null;
- }
-
- private String getDelimiter(){
- String delimiter = System.getProperty(PROPERTY_DELIMITER);
- if(delimiter == null)
- delimiter = isWindows() ? DELIMITER_WINDOWS : DELIMITER_UNIX;
- return delimiter;
- }
-
- private String searchExecutable(String command, String paths[]){
- if(paths == null)
- return null;
-
- for(int i = 0; i < paths.length; i++){
- File file = new File(paths[i], command.toString());
- if(file.isFile())
- return file.toString();
- }
- return null;
- }
-
- private boolean isWindows() {
- String prop = System.getProperty(PROPERTY_OS_NAME);
- return prop != null ? prop.toLowerCase().startsWith(PROPERTY_OS_VALUE) : false;
- }
}

Back to the top