Skip to content

Commit

Permalink
Implementation of compile output parser in gRPC command
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed May 19, 2023
1 parent aea5b2c commit 8c9c699
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/configuration"
"github.com/arduino/arduino-cli/i18n"
"github.com/arduino/arduino-cli/internal/builder/diagnostics"
"github.com/arduino/arduino-cli/inventory"
"github.com/arduino/arduino-cli/legacy/builder"
"github.com/arduino/arduino-cli/legacy/builder/types"
Expand Down Expand Up @@ -163,7 +164,25 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
return nil, err
}

var allDiagnostics diagnostics.Diagnostics
defer func() {
r.Diagnostics = allDiagnostics.ToRPC()
}()

builderCtx := &types.Context{}
builderCtx.CompilerOutputParser = func(cmdline []string, out []byte) {
compiler := diagnostics.DetectCompilerFromCommandLine(cmdline, false /* at the moment compiler-probing is not required */)
if compiler == nil {
logrus.Warnf("Could not detect compiler from: %s", cmdline)
return
}
diags, err := diagnostics.ParseCompilerOutput(compiler, out)
if err != nil {
logrus.Warnf("Error parsing compiler output: %s", err)
return
}
allDiagnostics = append(allDiagnostics, diags...)
}
builderCtx.PackageManager = pme
if pme.GetProfile() != nil {
builderCtx.LibrariesManager = lm
Expand Down

0 comments on commit 8c9c699

Please sign in to comment.