1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

bug 364733: Fixed problem with not picking environment correctly

This commit is contained in:
Andrew Gvozdev 2012-03-18 06:17:19 -04:00
parent 4b719a56c7
commit 13ab9fa3c4

View file

@ -127,18 +127,20 @@ public class CommandLauncher implements ICommandLauncher {
/** /**
* Parse array of "ENV=value" pairs to Properties. * Parse array of "ENV=value" pairs to Properties.
*/ */
private Properties parseEnv(String[] env) { private void parseEnvironment(String[] env) {
Properties envProperties = new Properties(); fEnvironment = null;
for (String envStr : env) { if (env != null) {
// Split "ENV=value" and put in Properties fEnvironment = new Properties();
int pos = envStr.indexOf('='); for (String envStr : env) {
if (pos < 0) // Split "ENV=value" and put in Properties
pos = envStr.length(); int pos = envStr.indexOf('=');
String key = envStr.substring(0, pos); if (pos < 0)
String value = envStr.substring(pos + 1); pos = envStr.length();
envProperties.put(key, value); String key = envStr.substring(0, pos);
String value = envStr.substring(pos + 1);
fEnvironment.put(key, value);
}
} }
return envProperties;
} }
/** /**
@ -162,27 +164,28 @@ public class CommandLauncher implements ICommandLauncher {
*/ */
@Override @Override
public Process execute(IPath commandPath, String[] args, String[] env, IPath workingDirectory, IProgressMonitor monitor) throws CoreException { public Process execute(IPath commandPath, String[] args, String[] env, IPath workingDirectory, IProgressMonitor monitor) throws CoreException {
parseEnvironment(env);
String envPathValue = (String) getEnvironment().get(PATH_ENV);
Boolean isFound = null; Boolean isFound = null;
String command = commandPath.toOSString(); String command = commandPath.toOSString();
String envPathValue = (String) getEnvironment().get(PATH_ENV); fCommandArgs = constructCommandArray(command, args);
try { if (Platform.getOS().equals(Platform.OS_WIN32)) {
fCommandArgs = constructCommandArray(command, args); // Handle cygwin link
if (Platform.getOS().equals(Platform.OS_WIN32)) { IPath location = PathUtil.findProgramLocation(command, envPathValue);
// Handle cygwin link isFound = location != null;
IPath location = PathUtil.findProgramLocation(command, envPathValue); if (location != null) {
isFound = location != null; try {
if (location != null) { fCommandArgs[0] = Cygwin.cygwinToWindowsPath(location.toString(), envPathValue);
try { } catch (Exception e) {
fCommandArgs[0] = Cygwin.cygwinToWindowsPath(location.toString(), envPathValue); // if no cygwin nothing to worry about
} catch (Exception e) {
// if no cygwin nothing to worry about
}
} }
} }
}
fEnvironment = parseEnv(env); File dir = workingDirectory != null ? workingDirectory.toFile() : null;
File dir = workingDirectory != null ? workingDirectory.toFile() : null;
try {
fProcess = ProcessFactory.getFactory().exec(fCommandArgs, env, dir); fProcess = ProcessFactory.getFactory().exec(fCommandArgs, env, dir);
fCommandArgs[0] = command; // to print original command on the console fCommandArgs[0] = command; // to print original command on the console
fErrorMessage = ""; //$NON-NLS-1$ fErrorMessage = ""; //$NON-NLS-1$