8000 [draft] [breaking] Added `support` field in `library.properties` by cmaglie · Pull Request #2155 · arduino/arduino-cli · GitHub
[go: up one dir, main page]

Skip to content

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

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
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
Next Next commit
Added FQBNMatcher class
  • Loading branch information
cmaglie committed Apr 20, 2023
commit f369bbd96d0dfd1c08dee97b89465daa61343e33
37 changes: 37 additions & 0 deletions arduino/cores/fqbn.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,40 @@ func (fqbn *FQBN) Match(target *FQBN) bool {
func (fqbn *FQBN) StringWithoutConfig() string {
return fqbn.Package + ":" + fqbn.PlatformArch + ":" + fqbn.BoardID
}

// FQBNMatcher contains a pattern to match an FQBN
type FQBNMatcher struct {
Package string
PlatformArch string
BoardID string
}

// ParseFQBNMatcher parse a formula for an FQBN pattern and returns the corresponding
// FQBNMatcher. In the formula is allowed the glob char `*`. The formula must contains
// the triple `PACKAGE:ARCHITECTURE:BOARDID`, some exaples are:
// - `arduino:avr:uno`
// - `*:avr:*`
// - `arduino:avr:mega*`
func ParseFQBNMatcher(formula string) (*FQBNMatcher, error) {
parts := strings.Split(strings.TrimSpace(formula), ":")
if len(parts) < 3 || len(parts) > 4 {
return nil, fmt.Errorf("invalid formula: %s", formula)
}
return &FQBNMatcher{
Package: parts[0],
PlatformArch: parts[1],
BoardID: parts[2],
}, nil
}

// Match checks if this FQBNMatcher matches the given fqbn
func (m *FQBNMatcher) Match(fqbn *FQBN) bool {
// TODO: allow in-fix syntax like `*name`
return (m.Package == fqbn.Package || m.Package == "*") &&
(m.PlatformArch == fqbn.PlatformArch || m.PlatformArch == "*") &&
(m.BoardID == fqbn.BoardID || m.BoardID == "*")
}

func (m *FQBNMatcher) String() string {
return m.Package + "." + m.PlatformArch + ":" + m.BoardID
}
0