@@ -36,6 +36,8 @@ import (
36
36
"sort"
37
37
"strings"
38
38
39
+ "github.com/bcmi-labs/arduino-cli/cores/packagemanager"
40
+
39
41
builder "github.com/arduino/arduino-builder"
40
42
"github.com/arduino/arduino-builder/types"
41
43
"github.com/arduino/arduino-builder/utils"
@@ -44,7 +46,6 @@ import (
44
46
"github.com/bcmi-labs/arduino-cli/common/formatter"
45
47
"github.com/bcmi-labs/arduino-cli/configs"
46
48
"github.com/bcmi-labs/arduino-cli/cores"
47
- "github.com/bcmi-labs/arduino-cli/cores/packageindex"
48
49
"github.com/bcmi-labs/arduino-cli/sketches"
49
50
"github.com/sirupsen/logrus"
50
51
"github.com/spf13/cobra"
@@ -198,18 +199,21 @@ func run(cmd *cobra.Command, args []string) {
198
199
}
199
200
// FIXME: this is building the CommandLine to run the builder; we should move it to a "cores.compute" pkg
200
201
// Add dependency tools paths to build properties with versions corresponding to specific core version.
201
- var packageIndex packageindex.Index
202
- packageindex .LoadIndex (& packageIndex )
203
- for _ , packageFromIndex := range packageIndex .Packages {
204
- if packageFromIndex .Name == packageName {
205
- for _ , platformFromIndex := range packageFromIndex .Platforms {
206
- if platformFromIndex .Architecture == coreName && platformFromIndex .Version == coreVersion {
207
- for _ , toolDependencyFromIndex := range platformFromIndex .ToolDependencies {
208
- if isInstalled , _ := cores .IsToolVersionInstalled (packageName , toolDependencyFromIndex .Name , toolDependencyFromIndex .Version ); ! isInstalled {
209
- formatter .PrintError (err , fmt .Sprintf ("Required tool version not found: %s - %s." , toolDependencyFromIndex .Name , toolDependencyFromIndex .Version ))
202
+ pm := packagemanager .PackageManager ()
203
+ if err := pm .LoadHardware (); err != nil {
204
+ formatter .PrintError (err , "Error loading hardware packages." )
205
+ os .Exit (commands .ErrCoreConfig )
206
+ }
207
+ for _ , targetPackage := range pm .GetPackages ().Packages {
208
+ if targetPackage .Name == packageName {
209
+ for _ , platform := range targetPackage .Platforms {
210
+ if platform .Architecture == coreName && platform .Releases [coreVersion ] != nil {
211
+ for _ , toolDep := range platform .Releases [coreVersion ].Dependencies {
212
+ if isInstalled , _ := cores .IsToolVersionInstalled (toolDep ); ! isInstalled {
213
+ formatter .PrintError (err , fmt .Sprintf ("Required tool version not found: %s - %s." , toolDep .ToolName , toolDep .ToolVersion ))
210
214
os .Exit (commands .ErrBadCall )
211
215
}
212
- property := "runtime.tools." + toolDependencyFromIndex . Name + ".path=" + filepath .Join (toolsFolder , toolDependencyFromIndex . Name , toolDependencyFromIndex . Version )
216
+ property := "runtime.tools." + toolDep . ToolName + ".path=" + filepath .Join (toolsFolder , toolDep . ToolName , toolDep . ToolVersion )
213
217
ctx .CustomBuildProperties = append (ctx .CustomBuildProperties , property )
214
218
}
215
219
break
0 commit comments