@@ -37,6 +37,7 @@ import (
37
37
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
38
38
"github.com/arduino/go-paths-helper"
39
39
"github.com/arduino/go-properties-orderedmap"
40
+ "github.com/sirupsen/logrus"
40
41
)
41
42
42
43
// ErrSketchCannotBeLocatedInBuildPath fixdoc
@@ -95,6 +96,8 @@ type Builder struct {
95
96
// This is a function used to parse the output of the compiler
96
97
// It is used to extract errors and warnings
97
98
compilerOutputParser diagnostics.CompilerOutputParserCB
99
+ // and here are the diagnostics parsed from the compiler
100
+ compilerDiagnostics diagnostics.Diagnostics
98
101
}
99
102
100
103
// buildArtifacts contains the result of various build
@@ -194,7 +197,7 @@ func NewBuilder(
194
197
logger .Warn (string (verboseOut ))
195
198
}
196
199
197
- return & Builder {
200
+ b := & Builder {
198
201
sketch : sk ,
199
202
buildProperties : buildProperties ,
200
203
buildPath : buildPath ,
@@ -231,7 +234,26 @@ func NewBuilder(
231
234
buildProperties .GetPath ("runtime.platform.path" ),
232
235
buildProperties .GetPath ("build.core.path" ), // TODO can we buildCorePath ?
233
236
),
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
235
257
}
236
258
237
259
// GetBuildProperties returns the build properties for running this build
@@ -254,6 +276,11 @@ func (b *Builder) ImportedLibraries() libraries.List {
254
276
return b .libsDetector .ImportedLibraries ()
255
277
}
256
278
279
+ // CompilerDiagnostics returns the parsed compiler diagnostics
280
+ func (b * Builder ) CompilerDiagnostics () diagnostics.Diagnostics {
281
+ return b .compilerDiagnostics
282
+ }
283
+
257
284
// Preprocess fixdoc
258
285
func (b * Builder ) Preprocess () ([]byte , error ) {
259
286
b .Progress .AddSubSteps (6 )
0 commit comments