Skip to content

Commit a48664b

Browse files
author
Akos Kitta
committed
Use BoardsManifest if Boards is not applicable
This patch falls back to the `BoardsManifest` when the `Boards` is not available. When the `Boards` are not installed, hence unavailable, the produced gRPC instance won't contain the `FQBN` but the `Name` only. Signed-off-by: Akos Kitta <[email protected]>
1 parent bbf497e commit a48664b

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

Diff for: commands/core/core.go

+23-7
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,30 @@ import (
2626
// Note: this function does not touch the "Installed" field of rpc.Platform as it's not always clear that the
2727
// platformRelease we're currently converting is actually installed.
2828
func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.Platform {
29-
boards := make([]*rpc.Board, len(platformRelease.Boards))
30-
i := 0
31-
for _, b := range platformRelease.Boards {
32-
boards[i] = &rpc.Board{
33-
Name: b.Name(),
34-
Fqbn: b.FQBN(),
29+
// If the boards are not installed yet, the `platformRelease.Boards` will be a zero length slice.
30+
// In such case, we have to use the `platformRelease.BoardsManifest` instead.
31+
// So that we can retrieve the name of the boards at least.
32+
var boards []*rpc.Board
33+
if len(platformRelease.Boards) > 0 {
34+
boards = make([]*rpc.Board, len(platformRelease.Boards))
35+
i := 0
36+
for _, b := range platformRelease.Boards {
37+
boards[i] = &rpc.Board{
38+
Name: b.Name(),
39+
Fqbn: b.FQBN(),
40+
}
41+
i++
42+
}
43+
} else {
44+
boards = make([]*rpc.Board, len(platformRelease.BoardsManifest))
45+
i := 0
46+
for _, m := range platformRelease.BoardsManifest {
47+
boards[i] = &rpc.Board{
48+
Name: m.Name,
49+
// FQBN is not available. Boards have to be installed first (-> `boards.txt`).
50+
}
51+
i++
3552
}
36-
i++
3753
}
3854

3955
result := &rpc.Platform{

0 commit comments

Comments
 (0)