3939
4040import com .google .protobuf .ByteString ;
4141
42+ import cc .arduino .CompilerProgressListener ;
4243import cc .arduino .cli .commands .ArduinoCoreGrpc .ArduinoCoreBlockingStub ;
4344import cc .arduino .cli .commands .Board .BoardDetailsReq ;
4445import 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