Skip to content

Commit

Permalink
Report board platform and build platform on compile JSON output (#1608
Browse files Browse the repository at this point in the history
)

* Added 'board_platform' and 'build_platform' fields in gRPC Compile command

* Report board platform and build platform on compile output
  • Loading branch information
cmaglie committed Dec 29, 2021
1 parent e63c798 commit 4506bf9
Show file tree
Hide file tree
Showing 10 changed files with 226 additions and 79 deletions.
9 changes: 9 additions & 0 deletions arduino/cores/cores.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/arduino/arduino-cli/arduino/resources"
"github.com/arduino/arduino-cli/i18n"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
paths "github.com/arduino/go-paths-helper"
properties "github.com/arduino/go-properties-orderedmap"
semver "go.bug.st/relaxed-semver"
Expand Down Expand Up @@ -342,6 +343,14 @@ func (release *PlatformRelease) String() string {
return release.Platform.String() + "@" + version
}

// ToRPCPlatformReference creates a gRPC PlatformReference message out of this PlatformRelease
func (release *PlatformRelease) ToRPCPlatformReference() *rpc.PlatformReference {
return &rpc.PlatformReference{
Id: release.Platform.String(),
Version: release.Version.String(),
}
}

// MarshalJSON provides a more user friendly serialization for
// PlatformRelease objects.
func (release *PlatformRelease) MarshalJSON() ([]byte, error) {
Expand Down
14 changes: 10 additions & 4 deletions commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
if p := builderCtx.BuildPath; p != nil {
r.BuildPath = p.String()
}
if pl := builderCtx.TargetPlatform; pl != nil {
r.BoardPlatform = pl.ToRPCPlatformReference()
}
if pl := builderCtx.ActualPlatform; pl != nil {
r.BuildPlatform = pl.ToRPCPlatformReference()
}
}()

// if --preprocess or --show-properties were passed, we can stop here
Expand Down Expand Up @@ -291,11 +297,11 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
}
importedLibs = append(importedLibs, rpcLib)
}
r.UsedLibraries = importedLibs

r.ExecutableSectionsSize = builderCtx.ExecutableSectionsSize.ToRPCExecutableSectionSizeArray()

logrus.Tracef("Compile %s for %s successful", sk.Name, fqbnIn)

return &rpc.CompileResponse{
UsedLibraries: importedLibs,
ExecutableSectionsSize: builderCtx.ExecutableSectionsSize.ToRPCExecutableSectionSizeArray(),
}, nil
return r, nil
}
54 changes: 29 additions & 25 deletions rpc/cc/arduino/cli/commands/v1/commands_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4506bf9

Please sign in to comment.