@@ -30,6 +30,7 @@ import (
3030 "github.com/arduino/arduino-cli/commands"
3131 "github.com/arduino/arduino-cli/configuration"
3232 "github.com/arduino/arduino-cli/i18n"
33+ "github.com/arduino/arduino-cli/internal/builder/diagnostics"
3334 "github.com/arduino/arduino-cli/inventory"
3435 "github.com/arduino/arduino-cli/legacy/builder"
3536 "github.com/arduino/arduino-cli/legacy/builder/types"
@@ -163,7 +164,25 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
163164 return nil , err
164165 }
165166
167+ var allDiagnostics diagnostics.Diagnostics
168+ defer func () {
169+ r .Diagnostics = allDiagnostics .ToRPC ()
170+ }()
171+
166172 builderCtx := & types.Context {}
173+ builderCtx .CompilerOutputParser = func (cmdline []string , out []byte ) {
174+ compiler := diagnostics .DetectCompilerFromCommandLine (cmdline , false /* at the moment compiler-probing is not required */ )
175+ if compiler == nil {
176+ logrus .Warnf ("Could not detect compiler from: %s" , cmdline )
177+ return
178+ }
179+ diags , err := diagnostics .ParseCompilerOutput (compiler , out )
180+ if err != nil {
181+ logrus .Warnf ("Error parsing compiler output: %s" , err )
182+ return
183+ }
184+ allDiagnostics = append (allDiagnostics , diags ... )
185+ }
167186 builderCtx .PackageManager = pme
168187 if pme .GetProfile () != nil {
169188 builderCtx .LibrariesManager = lm
0 commit comments