@@ -27,6 +27,7 @@ import (
2727 "unicode"
2828
2929 "github.com/arduino/arduino-cli/arduino/builder/internal/compilation"
30+ "github.com/arduino/arduino-cli/arduino/builder/internal/diagnostics"
3031 "github.com/arduino/arduino-cli/arduino/builder/internal/logger"
3132 "github.com/arduino/arduino-cli/arduino/builder/internal/progress"
3233 "github.com/arduino/arduino-cli/arduino/globals"
@@ -356,6 +357,7 @@ func CompileFiles(
356357 onlyUpdateCompilationDatabase bool ,
357358 compilationDatabase * compilation.Database ,
358359 jobs int ,
360+ compilerOutputParser diagnostics.CompilerOutputParserCB ,
359361 builderLogger * logger.BuilderLogger ,
360362 progress * progress.Struct ,
361363) (paths.PathList , error ) {
@@ -366,6 +368,7 @@ func CompileFiles(
366368 sourceDir ,
367369 false ,
368370 buildPath , buildProperties , includes ,
371+ compilerOutputParser ,
369372 builderLogger ,
370373 progress ,
371374 )
@@ -379,6 +382,7 @@ func CompileFilesRecursive(
379382 onlyUpdateCompilationDatabase bool ,
380383 compilationDatabase * compilation.Database ,
381384 jobs int ,
385+ compilerOutputParser diagnostics.CompilerOutputParserCB ,
382386 builderLogger * logger.BuilderLogger ,
383387 progress * progress.Struct ,
384388) (paths.PathList , error ) {
@@ -389,6 +393,7 @@ func CompileFilesRecursive(
389393 sourceDir ,
390394 true ,
391395 buildPath , buildProperties , includes ,
396+ compilerOutputParser ,
392397 builderLogger ,
393398 progress ,
394399 )
@@ -403,6 +408,7 @@ func compileFiles(
403408 buildPath * paths.Path ,
404409 buildProperties * properties.Map ,
405410 includes []string ,
411+ compilerOutputParser diagnostics.CompilerOutputParserCB ,
406412 builderLogger * logger.BuilderLogger ,
407413 progress * progress.Struct ,
408414) (paths.PathList , error ) {
@@ -437,6 +443,7 @@ func compileFiles(
437443 compilationDatabase ,
438444 onlyUpdateCompilationDatabase ,
439445 sourceDir , source , buildPath , buildProperties , includes , recipe ,
446+ compilerOutputParser ,
440447 builderLogger ,
441448 )
442449 if builderLogger .Verbose () {
@@ -502,6 +509,7 @@ func compileFileWithRecipe(
502509 buildProperties * properties.Map ,
503510 includes []string ,
504511 recipe string ,
512+ compilerOutputParser diagnostics.CompilerOutputParserCB ,
505513 builderLogger * logger.BuilderLogger ,
506514) (* paths.Path , []byte , []byte , []byte , error ) {
507515 verboseStdout , verboseInfo , errOut := & bytes.Buffer {}, & bytes.Buffer {}, & bytes.Buffer {}
@@ -552,6 +560,12 @@ func compileFileWithRecipe(
552560 }
553561 errOut .Write (stderr )
554562
563+ // Parse the output of the compiler to gather errors and warnings...
564+ if compilerOutputParser != nil {
565+ compilerOutputParser (command .GetArgs (), stdout )
566+ compilerOutputParser (command .GetArgs (), stderr )
567+ }
568+
555569 // ...and then return the error
556570 if err != nil {
557571 return nil , verboseInfo .Bytes (), verboseStdout .Bytes (), errOut .Bytes (), errors .WithStack (err )
0 commit comments