Skip to content

Use BoardsManifest if Boards is not applicable #294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions commands/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,30 @@ import (
// Note: this function does not touch the "Installed" field of rpc.Platform as it's not always clear that the
// platformRelease we're currently converting is actually installed.
func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.Platform {
boards := make([]*rpc.Board, len(platformRelease.Boards))
i := 0
for _, b := range platformRelease.Boards {
boards[i] = &rpc.Board{
Name: b.Name(),
Fqbn: b.FQBN(),
// If the boards are not installed yet, the `platformRelease.Boards` will be a zero length slice.
// In such case, we have to use the `platformRelease.BoardsManifest` instead.
// So that we can retrieve the name of the boards at least.
var boards []*rpc.Board
if len(platformRelease.Boards) > 0 {
boards = make([]*rpc.Board, len(platformRelease.Boards))
i := 0
for _, b := range platformRelease.Boards {
boards[i] = &rpc.Board{
Name: b.Name(),
Fqbn: b.FQBN(),
}
i++
}
} else {
boards = make([]*rpc.Board, len(platformRelease.BoardsManifest))
i := 0
for _, m := range platformRelease.BoardsManifest {
boards[i] = &rpc.Board{
Name: m.Name,
// FQBN is not available. Boards have to be installed first (-> `boards.txt`).
}
i++
}
i++
}

result := &rpc.Platform{
Expand Down