Skip to content

Commit b16f15c

Browse files
authored
Log platforms and libraries used during sketch compilation.
1 parent 3d097e5 commit b16f15c

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

internal/orchestrator/orchestrator.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
dockerClient "github.com/docker/docker/client"
2323
"github.com/gosimple/slug"
2424
"github.com/sirupsen/logrus"
25+
"go.bug.st/f"
2526
"gopkg.in/yaml.v3"
2627

2728
"github.com/arduino/arduino-app-cli/pkg/parser"
@@ -652,7 +653,7 @@ func getDevices() []string {
652653
}
653654

654655
func compileUploadSketch(ctx context.Context, sketchPath, buildPath string, w io.Writer) error {
655-
logrus.SetLevel(logrus.ErrorLevel)
656+
logrus.SetLevel(logrus.ErrorLevel) // Reduce the log level of arduino-cli
656657
srv := commands.NewArduinoCoreServer()
657658

658659
var inst *rpc.Instance
@@ -706,10 +707,9 @@ func compileUploadSketch(ctx context.Context, sketchPath, buildPath string, w io
706707
fmt.Println("\nAuto selected board:", name, "fqbn:", fqbn, "port:", port.Address)
707708

708709
// build the sketch
709-
server, _ := commands.CompilerServerToStreams(ctx, w, w, nil)
710+
server, getCompileResult := commands.CompilerServerToStreams(ctx, w, w, nil)
710711

711712
// TODO: add build cache
712-
// TODO: maybe handle resultCB.GetDiagnostics()
713713
err = srv.Compile(&rpc.CompileRequest{
714714
Instance: inst,
715715
Fqbn: fqbn,
@@ -721,6 +721,22 @@ func compileUploadSketch(ctx context.Context, sketchPath, buildPath string, w io
721721
return err
722722
}
723723

724+
// Output compilations details
725+
result := getCompileResult()
726+
f.Assert(result != nil, "Failed to get compilation result")
727+
// TODO: maybe handle result.GetDiagnostics()
728+
boardPlatform := result.GetBoardPlatform()
729+
if boardPlatform != nil {
730+
slog.Info("Board platform: " + boardPlatform.GetId() + " (" + boardPlatform.GetVersion() + ") in " + boardPlatform.GetInstallDir())
731+
}
732+
buildPlatform := result.GetBuildPlatform()
733+
if buildPlatform != nil && buildPlatform.GetInstallDir() != boardPlatform.GetInstallDir() {
734+
slog.Info("Build platform: " + buildPlatform.GetId() + " (" + buildPlatform.GetVersion() + ") in " + buildPlatform.GetInstallDir())
735+
}
736+
for _, lib := range result.GetUsedLibraries() {
737+
slog.Info("Used library " + lib.GetName() + " (" + lib.GetVersion() + ") in " + lib.GetInstallDir())
738+
}
739+
724740
stream, _ := commands.UploadToServerStreams(ctx, w, w)
725741
err = srv.Upload(&rpc.UploadRequest{
726742
Instance: inst,

0 commit comments

Comments
 (0)