GeneralCommandLine command = new GeneralCommandLine();
command.setExePath(rustc.getAbsolutePath());
command.addParameter("--version");
command.setWorkDirectory(rustc.getParent());
ProcessOutput output = new CapturingProcessHandler(
command.createProcess(),
Charset.defaultCharset(),
command.getCommandLineString()).runProcess();
if (output.getExitCode() != 0) {
LOG.error(
"rustc exited with invalid exit code: " +
output.getExitCode() + "\n" +
output.getStdout()
);
return null;
}
String[] lines = output.getStdout().split("\n");
if (lines.length > 2 || lines.length == 0) {
LOG.error("invalid rustc output: expected 1 or 2 lines, got " + lines.length);
return null;
}
String[] line1 = lines[0].split(" ");