@@ -32,6 +32,7 @@ import (
32
32
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
33
33
"github.com/arduino/go-paths-helper"
34
34
"github.com/arduino/go-properties-orderedmap"
35
+ "github.com/sirupsen/logrus"
35
36
)
36
37
37
38
// ErrSketchCannotBeLocatedInBuildPath fixdoc
@@ -90,6 +91,9 @@ type Builder struct {
90
91
// This is a function used to parse the output of the compiler
91
92
// It is used to extract errors and warnings
92
93
compilerOutputParser diagnostics.CompilerOutputParserCB
94
+ // There are the diagnostics parsed from the compiler
95
+ compilerDiagnostics diagnostics.Diagnostics
96
+ // TODO: diagnostics can be done better here
93
97
}
94
98
95
99
// buildArtifacts contains the result of various build
@@ -187,7 +191,7 @@ func NewBuilder(
187
191
logger .Warn (string (verboseOut ))
188
192
}
189
193
190
- return & Builder {
194
+ b := & Builder {
191
195
sketch : sk ,
192
196
buildProperties : buildProperties ,
193
197
buildPath : buildPath ,
@@ -224,7 +228,26 @@ func NewBuilder(
224
228
buildProperties .GetPath ("runtime.platform.path" ),
225
229
buildProperties .GetPath ("build.core.path" ), // TODO can we buildCorePath ?
226
230
),
227
- }, nil
231
+ }
232
+
233
+ b .compilerOutputParser = func (cmdline []string , out []byte ) {
234
+ compiler := diagnostics .DetectCompilerFromCommandLine (
235
+ cmdline ,
236
+ false , // at the moment compiler-probing is not required
237
+ )
238
+ if compiler == nil {
239
+ logrus .Warnf ("Could not detect compiler from: %s" , cmdline )
240
+ return
241
+ }
242
+ diags , err := diagnostics .ParseCompilerOutput (compiler , out )
243
+ if err != nil {
244
+ logrus .Warnf ("Error parsing compiler output: %s" , err )
245
+ return
246
+ }
247
+ b .compilerDiagnostics = append (b .compilerDiagnostics , diags ... )
248
+ }
249
+
250
+ return b , nil
228
251
}
229
252
230
253
// GetBuildProperties returns the build properties for running this build
@@ -247,6 +270,11 @@ func (b *Builder) ImportedLibraries() libraries.List {
247
270
return b .libsDetector .ImportedLibraries ()
248
271
}
249
272
273
+ // CompilerDiagnostics returns the parsed compiler diagnostics
274
+ func (b * Builder ) CompilerDiagnostics () diagnostics.Diagnostics {
275
+ return b .compilerDiagnostics
276
+ }
277
+
250
278
// Preprocess fixdoc
251
279
func (b * Builder ) Preprocess () error {
252
280
b .Progress .AddSubSteps (6 )
0 commit comments