1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

Updating arduino-builder to 1.0.0-beta24

This commit is contained in:
Federico Fissore 2015-10-06 10:16:41 +02:00
parent db6123531e
commit aa654ba242
10 changed files with 32 additions and 10 deletions

View File

@ -30,9 +30,11 @@
package cc.arduino;
import cc.arduino.i18n.I18NAwareMessageConsumer;
import cc.arduino.packages.BoardPort;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.PumpStreamHandler;
import org.apache.commons.lang3.StringUtils;
import processing.app.*;
import processing.app.debug.*;
import processing.app.helpers.PreferencesMap;
@ -128,13 +130,14 @@ public class Compiler implements MessageConsumer {
TargetPlatform platform = board.getContainerPlatform();
TargetPackage aPackage = platform.getContainerPackage();
String vidpid = VIDPID();
PreferencesMap prefs = loadPreferences(board, platform, aPackage);
PreferencesMap prefs = loadPreferences(board, platform, aPackage, vidpid);
MessageConsumerOutputStream out = new MessageConsumerOutputStream(new ProgressAwareMessageConsumer(new I18NAwareMessageConsumer(System.out), progListener), "\n");
MessageConsumerOutputStream err = new MessageConsumerOutputStream(new I18NAwareMessageConsumer(System.err, Compiler.this), "\n");
callArduinoBuilder(board, platform, aPackage, BuilderAction.COMPILE, new PumpStreamHandler(out, err));
callArduinoBuilder(board, platform, aPackage, vidpid, BuilderAction.COMPILE, new PumpStreamHandler(out, err));
out.flush();
err.flush();
@ -152,12 +155,27 @@ public class Compiler implements MessageConsumer {
return sketch.getName() + ".ino";
}
private PreferencesMap loadPreferences(TargetBoard board, TargetPlatform platform, TargetPackage aPackage) throws RunnerException, IOException {
private String VIDPID() {
BoardPort boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
if (boardPort == null) {
return "";
}
String vid = boardPort.getPrefs().get("vid");
String pid = boardPort.getPrefs().get("pid");
if (StringUtils.isEmpty(vid) || StringUtils.isEmpty(pid)) {
return "";
}
return vid.toUpperCase() + "_" + pid.toUpperCase();
}
private PreferencesMap loadPreferences(TargetBoard board, TargetPlatform platform, TargetPackage aPackage, String vidpid) throws RunnerException, IOException {
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
MessageConsumerOutputStream err = new MessageConsumerOutputStream(new I18NAwareMessageConsumer(new PrintStream(stderr), Compiler.this), "\n");
try {
callArduinoBuilder(board, platform, aPackage, BuilderAction.DUMP_PREFS, new PumpStreamHandler(stdout, err));
callArduinoBuilder(board, platform, aPackage, vidpid, BuilderAction.DUMP_PREFS, new PumpStreamHandler(stdout, err));
} catch (RunnerException e) {
System.err.println(new String(stderr.toByteArray()));
throw e;
@ -167,7 +185,7 @@ public class Compiler implements MessageConsumer {
return prefs;
}
private void callArduinoBuilder(TargetBoard board, TargetPlatform platform, TargetPackage aPackage, BuilderAction action, PumpStreamHandler streamHandler) throws RunnerException {
private void callArduinoBuilder(TargetBoard board, TargetPlatform platform, TargetPackage aPackage, String vidpid, BuilderAction action, PumpStreamHandler streamHandler) throws RunnerException {
File executable = BaseNoGui.getContentFile("arduino-builder");
CommandLine commandLine = new CommandLine(executable);
commandLine.addArgument(action.value, false);
@ -197,6 +215,10 @@ public class Compiler implements MessageConsumer {
String fqbn = Stream.of(aPackage.getId(), platform.getId(), board.getId(), boardOptions(board)).filter(s -> !s.isEmpty()).collect(Collectors.joining(":"));
commandLine.addArgument("-fqbn=" + fqbn, false);
if (!"".equals(vidpid)) {
commandLine.addArgument("-vid-pid=" + vidpid, false);
}
commandLine.addArgument("-ide-version=" + BaseNoGui.REVISION, false);
commandLine.addArgument("-build-path", false);
commandLine.addArgument("\"" + buildPath + "\"", false);

View File

@ -1 +0,0 @@
23ba6fb0969cf81bafb1d3c37b9d491e332fae71

View File

@ -0,0 +1 @@
d8c3e22428fa0953038f2ac21cd7be6d614fee30

View File

@ -1 +0,0 @@
c2e8bf47d10112f1145976792032121041735414

View File

@ -0,0 +1 @@
329b5e616165fa5cf7414a75f5e544d598dc944f

View File

@ -1 +0,0 @@
725c998d08c73fb292fbd558106494acf7d1f9cf

View File

@ -0,0 +1 @@
d8f371c06abce0a177101a16ed90d8e3ee989d37

View File

@ -1 +0,0 @@
f54e4dc2d71a2f1e0141afee7f28f9d896c11593

View File

@ -0,0 +1 @@
5efc19b5245b994f71ceae41f9da4c4aab67bd16

View File

@ -71,7 +71,7 @@
</or>
</condition>
<property name="ARDUINO-BUILDER-VERSION" value="1.0.0-beta23" />
<property name="ARDUINO-BUILDER-VERSION" value="1.0.0-beta24" />
<!-- Libraries required for running arduino -->
<fileset dir=".." id="runtime.jars">