@@ -26,10 +26,10 @@ import (
26
26
27
27
"github.com/arduino/arduino-cli/arduino/cores"
28
28
"github.com/arduino/arduino-cli/arduino/cores/packageindex"
29
- "github.com/arduino/go-paths-helper"
29
+ paths "github.com/arduino/go-paths-helper"
30
30
properties "github.com/arduino/go-properties-orderedmap"
31
31
"github.com/sirupsen/logrus"
32
- "go.bug.st/relaxed-semver"
32
+ semver "go.bug.st/relaxed-semver"
33
33
)
34
34
35
35
// PackageManager defines the superior oracle which understands all about
@@ -354,6 +354,36 @@ func (pm *PackageManager) GetAllInstalledToolsReleases() []*cores.ToolRelease {
354
354
return tools
355
355
}
356
356
357
+ // InstalledPlatformReleases returns all installed PlatformReleases. This function is
358
+ // useful to range all PlatformReleases in for loops.
359
+ func (pm * PackageManager ) InstalledPlatformReleases () []* cores.PlatformRelease {
360
+ platforms := []* cores.PlatformRelease {}
361
+ for _ , targetPackage := range pm .packages .Packages {
362
+ for _ , platform := range targetPackage .Platforms {
363
+ for _ , release := range platform .GetAllInstalled () {
364
+ platforms = append (platforms , release )
365
+ }
366
+ }
367
+ }
368
+ return platforms
369
+ }
370
+
371
+ // InstalledBoards returns all installed Boards. This function is useful to range
372
+ // all Boards in for loops.
373
+ func (pm * PackageManager ) InstalledBoards () []* cores.Board {
374
+ boards := []* cores.Board {}
375
+ for _ , targetPackage := range pm .packages .Packages {
376
+ for _ , platform := range targetPackage .Platforms {
377
+ for _ , release := range platform .GetAllInstalled () {
378
+ for _ , board := range release .Boards {
379
+ boards = append (boards , board )
380
+ }
381
+ }
382
+ }
383
+ }
384
+ return boards
385
+ }
386
+
357
387
func (pm * PackageManager ) FindToolsRequiredForBoard (board * cores.Board ) ([]* cores.ToolRelease , error ) {
358
388
pm .Log .Infof ("Searching tools required for board %s" , board )
359
389
0 commit comments