Skip to content

Commit 9b5dd01

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

File tree

8 files changed

+416
-353
lines changed

8 files changed

+416
-353
lines changed

commands/board/listall.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,34 @@ func ListAll(ctx context.Context, req *rpc.BoardListAllReq) (*rpc.BoardListAllRe
4848
list := &rpc.BoardListAllResp{Boards: []*rpc.BoardListItem{}}
4949
for _, targetPackage := range pm.Packages {
5050
for _, platform := range targetPackage.Platforms {
51-
platformRelease := pm.GetInstalledPlatformRelease(platform)
52-
if platformRelease == nil {
51+
installedPlatformRelease := pm.GetInstalledPlatformRelease(platform)
52+
// We only want to list boards for installed platforms
53+
if installedPlatformRelease == nil {
5354
continue
5455
}
55-
for _, board := range platformRelease.Boards {
56+
57+
installedVersion := ""
58+
if installedPlatformRelease != nil {
59+
installedVersion = installedPlatformRelease.Version.String()
60+
}
61+
62+
latestVersion := ""
63+
if latestPlatformRelease := platform.GetLatestRelease(); latestPlatformRelease != nil {
64+
latestVersion = latestPlatformRelease.Version.String()
65+
}
66+
67+
rpcPlatform := &rpc.Platform{
68+
ID: platform.String(),
69+
Installed: installedVersion,
70+
Latest: latestVersion,
71+
Name: platform.Name,
72+
Maintainer: platform.Package.Maintainer,
73+
Website: platform.Package.WebsiteURL,
74+
Email: platform.Package.Email,
75+
ManuallyInstalled: platform.ManuallyInstalled,
76+
}
77+
78+
for _, board := range installedPlatformRelease.Boards {
5679
if !match(board.Name()) {
5780
continue
5881
}
@@ -63,6 +86,7 @@ func ListAll(ctx context.Context, req *rpc.BoardListAllReq) (*rpc.BoardListAllRe
6386
Name: board.Name(),
6487
FQBN: board.FQBN(),
6588
IsHidden: board.IsHidden(),
89+
Platform: rpcPlatform,
6690
})
6791
}
6892
}

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)