Skip to content

Commit 37d30b3

Browse files
committed
Builder now support parsing of compiler output
1 parent ee69f2e commit 37d30b3

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

Diff for: arduino/builder/builder.go

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"github.com/arduino/arduino-cli/arduino/builder/internal/compilation"
2727
"github.com/arduino/arduino-cli/arduino/builder/internal/detector"
28+
"github.com/arduino/arduino-cli/arduino/builder/internal/diagnostics"
2829
"github.com/arduino/arduino-cli/arduino/builder/internal/logger"
2930
"github.com/arduino/arduino-cli/arduino/builder/internal/progress"
3031
"github.com/arduino/arduino-cli/arduino/builder/internal/utils"
@@ -90,6 +91,10 @@ type Builder struct {
9091
buildOptions *buildOptions
9192

9293
libsDetector *detector.SketchLibrariesDetector
94+
95+
// This is a function used to parse the output of the compiler
96+
// It is used to extract errors and warnings
97+
compilerOutputParser diagnostics.CompilerOutputParserCB
9398
}
9499

95100
// buildArtifacts contains the result of various build

Diff for: arduino/builder/compilation.go

+6
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ func (b *Builder) compileFileWithRecipe(
166166
}
167167
b.logger.WriteStderr(commandStderr.Bytes())
168168

169+
// Parse the output of the compiler to gather errors and warnings...
170+
if b.compilerOutputParser != nil {
171+
b.compilerOutputParser(command.GetArgs(), commandStdout.Bytes())
172+
b.compilerOutputParser(command.GetArgs(), commandStderr.Bytes())
173+
}
174+
169175
// ...and then return the error
170176
if err != nil {
171177
return nil, errors.WithStack(err)

Diff for: arduino/builder/internal/diagnostics/parser.go

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This file is part of arduino-cli.
2+
//
3+
// Copyright 2023 ARDUINO SA (http://www.arduino.cc/)
4+
//
5+
// This software is released under the GNU General Public License version 3,
6+
// which covers the main part of arduino-cli.
7+
// The terms of this license can be found at:
8+
// https://www.gnu.org/licenses/gpl-3.0.en.html
9+
//
10+
// You can be released from the requirements of the above licenses by purchasing
11+
// a commercial license. Buying such a license is mandatory if you want to
12+
// modify or otherwise use the software for commercial activities involving the
13+
// Arduino software without disclosing the source code of your own applications.
14+
// To purchase a commercial license, send an email to [email protected].
15+
16+
package diagnostics
17+
18+
// CompilerOutputParserCB is a callback function that is called to feed a parser
19+
// with the plain-text compiler output.
20+
type CompilerOutputParserCB func(cmdline []string, out []byte)

0 commit comments

Comments
 (0)