Skip to content

Commit fb50928

Browse files
committed
Add board's platform to board listall json output
1 parent b2b9fba commit fb50928

File tree

8 files changed

+425
-352
lines changed

8 files changed

+425
-352
lines changed

commands/board/listall.go

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"errors"
2121
"strings"
2222

23+
"github.com/arduino/arduino-cli/arduino/cores"
2324
"github.com/arduino/arduino-cli/commands"
2425
rpc "github.com/arduino/arduino-cli/rpc/commands"
2526
)
@@ -48,10 +49,42 @@ func ListAll(ctx context.Context, req *rpc.BoardListAllReq) (*rpc.BoardListAllRe
4849
list := &rpc.BoardListAllResp{Boards: []*rpc.BoardListItem{}}
4950
for _, targetPackage := range pm.Packages {
5051
for _, platform := range targetPackage.Platforms {
51-
platformRelease := pm.GetInstalledPlatformRelease(platform)
52-
if platformRelease == nil {
52+
installedPlatformRelease := pm.GetInstalledPlatformRelease(platform)
53+
latestPlatformRelease := platform.GetLatestRelease()
54+
55+
// No way to get list of boards if both releases are not found
56+
if installedPlatformRelease == nil && latestPlatformRelease == nil {
5357
continue
5458
}
59+
60+
installedVersion := ""
61+
if installedPlatformRelease != nil {
62+
installedVersion = installedPlatformRelease.Version.String()
63+
}
64+
65+
latestVersion := ""
66+
if latestPlatformRelease != nil {
67+
latestVersion = latestPlatformRelease.Version.String()
68+
}
69+
70+
rpcPlatform := &rpc.Platform{
71+
ID: platform.String(),
72+
Installed: installedVersion,
73+
Latest: latestVersion,
74+
Name: platform.Name,
75+
Maintainer: platform.Package.Maintainer,
76+
Website: platform.Package.WebsiteURL,
77+
Email: platform.Package.Email,
78+
ManuallyInstalled: platform.ManuallyInstalled,
79+
}
80+
81+
var platformRelease *cores.PlatformRelease
82+
if installedPlatformRelease != nil {
83+
platformRelease = installedPlatformRelease
84+
} else {
85+
platformRelease = latestPlatformRelease
86+
}
87+
5588
for _, board := range platformRelease.Boards {
5689
if !match(board.Name()) {
5790
continue
@@ -63,6 +96,7 @@ func ListAll(ctx context.Context, req *rpc.BoardListAllReq) (*rpc.BoardListAllRe
6396
Name: board.Name(),
6497
FQBN: board.FQBN(),
6598
IsHidden: board.IsHidden(),
99+
Platform: rpcPlatform,
66100
})
67101
}
68102
}

rpc/commands/board.pb.go

Lines changed: 28 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rpc/commands/board.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,6 @@ message BoardListItem {
235235
string VID = 4;
236236
// Product ID
237237
string PID = 5;
238+
// Platform this board belongs to
239+
Platform platform = 6;
238240
}

0 commit comments

Comments
 (0)