Skip to content

Commit 56be370

Browse files
committed
Compiler now read progress through GRPC
1 parent b6566f6 commit 56be370

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

arduino-core/src/cc/arduino/Compiler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ public String build(List<CompilerProgressListener> progListeners, boolean export
205205

206206
CompileResult result;
207207
try {
208-
MessageConsumerOutputStream out = new MessageConsumerOutputStream(new ProgressAwareMessageConsumer(new I18NAwareMessageConsumer(System.out, System.err), progListeners), "\n");
208+
MessageConsumerOutputStream out = new MessageConsumerOutputStream(new I18NAwareMessageConsumer(System.out, System.err), "\n");
209209
MessageConsumerOutputStream err = new MessageConsumerOutputStream(new I18NAwareMessageConsumer(System.err, this), "\n");
210210

211-
result = core.compile(req.build(), out, err);
211+
result = core.compile(req.build(), out, err, progListeners);
212212

213213
out.flush();
214214
err.flush();

arduino-core/src/cc/arduino/cli/ArduinoCoreInstance.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
import com.google.protobuf.ByteString;
4141

42+
import cc.arduino.CompilerProgressListener;
4243
import cc.arduino.cli.commands.ArduinoCoreGrpc.ArduinoCoreBlockingStub;
4344
import cc.arduino.cli.commands.Board.BoardDetailsReq;
4445
import cc.arduino.cli.commands.Board.BoardDetailsResp;
@@ -91,8 +92,8 @@ public void boardDetails(String fqbn) throws StatusException {
9192
}
9293
}
9394

94-
public CompileResult compile(CompileReq req, OutputStream out,
95-
OutputStream err) throws StatusException {
95+
public CompileResult compile(CompileReq req, OutputStream out, OutputStream err,
96+
List<CompilerProgressListener> progressListeners) throws StatusException {
9697
req = CompileReq.newBuilder(req) //
9798
.setInstance(instance) //
9899
.build();
@@ -108,6 +109,13 @@ public CompileResult compile(CompileReq req, OutputStream out,
108109
ByteString errdata = resp.getErrStream();
109110
if (errdata != null)
110111
err.write(errdata.toByteArray());
112+
TaskProgress taskProgress = resp.getTaskProgress();
113+
if (taskProgress != null) {
114+
float progress = taskProgress.getPercentCompleted();
115+
if (progress > 0) {
116+
progressListeners.forEach(l -> l.progress((int) progress));
117+
}
118+
}
111119
} catch (IOException e) {
112120
e.printStackTrace();
113121
}

0 commit comments

Comments
 (0)