Skip to content
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

[draft] [breaking] Added support field in library.properties #2155

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added SupportedFQBN field in Library and updated lib loader
  • Loading branch information
cmaglie committed Apr 20, 2023
commit 74977ee955afb8d5db592fa3bd787990aa0b2384
1 change: 1 addition & 0 deletions arduino/libraries/libraries.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type Library struct {
Website string
Category string
Architectures []string
SupportedFQBN []*cores.FQBNMatcher

Types []string `json:"types,omitempty"`

Expand Down
11 changes: 10 additions & 1 deletion arduino/libraries/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"strings"

"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/arduino/globals"
"github.com/arduino/arduino-cli/arduino/sketch"
"github.com/arduino/go-paths-helper"
Expand Down Expand Up @@ -82,7 +83,15 @@ func makeNewLibrary(libraryDir *paths.Path, location LibraryLocation) (*Library,
libProperties.Set("architectures", "*")
}
library.Architectures = commaSeparatedToList(libProperties.Get("architectures"))

if supported := libProperties.Get("supported"); supported != "" {
for _, formula := range strings.Split(supported, ",") {
constraint, err := cores.ParseFQBNMatcher(formula)
if err != nil {
return nil, errors.New(tr("invalid value '%[1]s': %[2]s", formula, err))
}
library.SupportedFQBN = append(library.SupportedFQBN, constraint)
}
}
libProperties.Set("category", strings.TrimSpace(libProperties.Get("category")))
if !ValidCategories[libProperties.Get("category")] {
libProperties.Set("category", "Uncategorized")
Expand Down