39
39
40
40
import com .google .protobuf .ByteString ;
41
41
42
+ import cc .arduino .CompilerProgressListener ;
42
43
import cc .arduino .cli .commands .ArduinoCoreGrpc .ArduinoCoreBlockingStub ;
43
44
import cc .arduino .cli .commands .Board .BoardDetailsReq ;
44
45
import cc .arduino .cli .commands .Board .BoardDetailsResp ;
@@ -91,14 +92,14 @@ public void boardDetails(String fqbn) throws StatusException {
91
92
}
92
93
}
93
94
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 {
96
97
req = CompileReq .newBuilder (req ) //
97
98
.setInstance (instance ) //
98
99
.build ();
99
100
try {
100
101
Iterator <CompileResp > stream = stub .compile (req );
101
- CompileResult result = CompileResult .error ;
102
+ CompileResult result = CompileResult .compile_error ;
102
103
while (stream .hasNext ()) {
103
104
CompileResp resp = stream .next ();
104
105
try {
@@ -108,6 +109,13 @@ public CompileResult compile(CompileReq req, OutputStream out,
108
109
ByteString errdata = resp .getErrStream ();
109
110
if (errdata != null )
110
111
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
+ }
111
119
} catch (IOException e ) {
112
120
e .printStackTrace ();
113
121
}
0 commit comments