@@ -37,6 +37,7 @@ import (
3737 rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
3838 "github.com/arduino/go-paths-helper"
3939 "github.com/arduino/go-properties-orderedmap"
40+ "github.com/sirupsen/logrus"
4041)
4142
4243// ErrSketchCannotBeLocatedInBuildPath fixdoc
@@ -95,6 +96,8 @@ type Builder struct {
9596 // This is a function used to parse the output of the compiler
9697 // It is used to extract errors and warnings
9798 compilerOutputParser diagnostics.CompilerOutputParserCB
99+ // and here are the diagnostics parsed from the compiler
100+ compilerDiagnostics diagnostics.Diagnostics
98101}
99102
100103// buildArtifacts contains the result of various build
@@ -194,7 +197,7 @@ func NewBuilder(
194197 logger .Warn (string (verboseOut ))
195198 }
196199
197- return & Builder {
200+ b := & Builder {
198201 sketch : sk ,
199202 buildProperties : buildProperties ,
200203 buildPath : buildPath ,
@@ -231,7 +234,26 @@ func NewBuilder(
231234 buildProperties .GetPath ("runtime.platform.path" ),
232235 buildProperties .GetPath ("build.core.path" ), // TODO can we buildCorePath ?
233236 ),
234- }, nil
237+ }
238+
239+ b .compilerOutputParser = func (cmdline []string , out []byte ) {
240+ compiler := diagnostics .DetectCompilerFromCommandLine (
241+ cmdline ,
242+ false , // at the moment compiler-probing is not required
243+ )
244+ if compiler == nil {
245+ logrus .Warnf ("Could not detect compiler from: %s" , cmdline )
246+ return
247+ }
248+ diags , err := diagnostics .ParseCompilerOutput (compiler , out )
249+ if err != nil {
250+ logrus .Warnf ("Error parsing compiler output: %s" , err )
251+ return
252+ }
253+ b .compilerDiagnostics = append (b .compilerDiagnostics , diags ... )
254+ }
255+
256+ return b , nil
235257}
236258
237259// GetBuildProperties returns the build properties for running this build
@@ -254,6 +276,11 @@ func (b *Builder) ImportedLibraries() libraries.List {
254276 return b .libsDetector .ImportedLibraries ()
255277}
256278
279+ // CompilerDiagnostics returns the parsed compiler diagnostics
280+ func (b * Builder ) CompilerDiagnostics () diagnostics.Diagnostics {
281+ return b .compilerDiagnostics
282+ }
283+
257284// Preprocess fixdoc
258285func (b * Builder ) Preprocess () ([]byte , error ) {
259286 b .Progress .AddSubSteps (6 )
0 commit comments