Skip to content

Commit 4506bf9

Browse files
authored
Report board platform and build platform on compile JSON output (#1608)
* Added 'board_platform' and 'build_platform' fields in gRPC Compile command * Report board platform and build platform on compile output
1 parent e63c798 commit 4506bf9

File tree

10 files changed

+226
-79
lines changed

10 files changed

+226
-79
lines changed

arduino/cores/cores.go

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/arduino/arduino-cli/arduino/resources"
2525
"github.com/arduino/arduino-cli/i18n"
26+
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2627
paths "github.com/arduino/go-paths-helper"
2728
properties "github.com/arduino/go-properties-orderedmap"
2829
semver "go.bug.st/relaxed-semver"
@@ -342,6 +343,14 @@ func (release *PlatformRelease) String() string {
342343
return release.Platform.String() + "@" + version
343344
}
344345

346+
// ToRPCPlatformReference creates a gRPC PlatformReference message out of this PlatformRelease
347+
func (release *PlatformRelease) ToRPCPlatformReference() *rpc.PlatformReference {
348+
return &rpc.PlatformReference{
349+
Id: release.Platform.String(),
350+
Version: release.Version.String(),
351+
}
352+
}
353+
345354
// MarshalJSON provides a more user friendly serialization for
346355
// PlatformRelease objects.
347356
func (release *PlatformRelease) MarshalJSON() ([]byte, error) {

commands/compile/compile.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
217217
if p := builderCtx.BuildPath; p != nil {
218218
r.BuildPath = p.String()
219219
}
220+
if pl := builderCtx.TargetPlatform; pl != nil {
221+
r.BoardPlatform = pl.ToRPCPlatformReference()
222+
}
223+
if pl := builderCtx.ActualPlatform; pl != nil {
224+
r.BuildPlatform = pl.ToRPCPlatformReference()
225+
}
220226
}()
221227

222228
// if --preprocess or --show-properties were passed, we can stop here
@@ -291,11 +297,11 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
291297
}
292298
importedLibs = append(importedLibs, rpcLib)
293299
}
300+
r.UsedLibraries = importedLibs
301+
302+
r.ExecutableSectionsSize = builderCtx.ExecutableSectionsSize.ToRPCExecutableSectionSizeArray()
294303

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

297-
return &rpc.CompileResponse{
298-
UsedLibraries: importedLibs,
299-
ExecutableSectionsSize: builderCtx.ExecutableSectionsSize.ToRPCExecutableSectionSizeArray(),
300-
}, nil
306+
return r, nil
301307
}

rpc/cc/arduino/cli/commands/v1/commands_grpc.pb.go

+29-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)