Merge remote-tracking branch 'origin/master'

This commit is contained in:
Daniil Ovchinnikov
2015-02-09 17:43:31 +03:00
2 changed files with 22 additions and 18 deletions
@@ -31,12 +31,13 @@ import java.io.PrintWriter;
* @author traff
*/
public class RunnerMediator {
public static final Logger LOG = Logger.getInstance("#com.intellij.execution.process.RunnerMediator");
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.process.RunnerMediator");
private static final char IAC = (char)5;
private static final char BRK = (char)3;
private static final char C = (char)5;
private static final String STANDARD_RUNNERW = "runnerw.exe";
private static final String IDEA_RUNNERW = "IDEA_RUNNERW";
/**
* Creates default runner mediator
@@ -79,28 +80,32 @@ public class RunnerMediator {
@Nullable
private static String getRunnerPath() {
if (SystemInfo.isWindows) {
final String path = System.getenv("IDEA_RUNNERW");
if (path != null && new File(path).exists()) {
return path;
}
File runnerw = new File(PathManager.getBinPath(), STANDARD_RUNNERW);
if (runnerw.exists()) {
return runnerw.getPath();
}
return null;
}
else {
if (!SystemInfo.isWindows) {
throw new IllegalStateException("There is no need of runner under unix based OS");
}
final String path = System.getenv(IDEA_RUNNERW);
if (path != null) {
if (new File(path).exists()) {
return path;
}
LOG.warn("Cannot locate " + STANDARD_RUNNERW + " by " + IDEA_RUNNERW + " environment variable (" + path + ")");
}
File runnerw = new File(PathManager.getBinPath(), STANDARD_RUNNERW);
if (runnerw.exists()) {
return runnerw.getPath();
}
LOG.warn("Cannot locate " + STANDARD_RUNNERW + " by default path (" + runnerw.getAbsolutePath() + ")");
return null;
}
static void injectRunnerCommand(@NotNull GeneralCommandLine commandLine) {
static boolean injectRunnerCommand(@NotNull GeneralCommandLine commandLine) {
final String path = getRunnerPath();
if (path != null) {
commandLine.getParametersList().addAt(0, commandLine.getExePath());
commandLine.setExePath(path);
return true;
}
return false;
}
/**
@@ -35,13 +35,12 @@ public class RunnerWinProcess extends ProcessWrapper {
}
@NotNull
public static RunnerWinProcess create(@NotNull GeneralCommandLine commandLine) throws ExecutionException {
public static Process create(@NotNull GeneralCommandLine commandLine) throws ExecutionException {
if (!SystemInfo.isWindows) {
throw new RuntimeException(RunnerWinProcess.class.getSimpleName() + " works on Windows only!");
}
RunnerMediator.injectRunnerCommand(commandLine);
boolean success = RunnerMediator.injectRunnerCommand(commandLine);
Process process = commandLine.createProcess();
return new RunnerWinProcess(process);
return success ? new RunnerWinProcess(process) : process;
}
}