Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bad9811

Browse files
committedJun 30, 2020
Compiler now read progress through GRPC
1 parent e5c7351 commit bad9811

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed
 

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

Lines changed: 3 additions & 3 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();
@@ -219,7 +219,7 @@ public String build(List<CompilerProgressListener> progListeners, boolean export
219219
if (exception != null)
220220
throw exception;
221221

222-
if (result == CompileResult.error) {
222+
if (result == CompileResult.compile_error) {
223223
RunnerException re = new RunnerException(I18n.format(tr("Error compiling for board {0}."), board.getName()));
224224
re.hideStackTrace();
225225
throw re;

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

Lines changed: 11 additions & 3 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,14 +92,14 @@ 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();
99100
try {
100101
Iterator<CompileResp> stream = stub.compile(req);
101-
CompileResult result = CompileResult.error;
102+
CompileResult result = CompileResult.compile_error;
102103
while (stream.hasNext()) {
103104
CompileResp resp = stream.next();
104105
try {
@@ -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)
Please sign in to comment.