diff --git a/arduino/cores/packagemanager/download.go b/arduino/cores/packagemanager/download.go index f3a5877c8a6..5baf34d2b9c 100644 --- a/arduino/cores/packagemanager/download.go +++ b/arduino/cores/packagemanager/download.go @@ -43,12 +43,12 @@ func (platform *PlatformReference) String() string { // FindPlatform returns the Platform matching the PlatformReference or nil if not found. // The PlatformVersion field of the reference is ignored. -func (pme *Explorer) FindPlatform(ref *PlatformReference) *cores.Platform { - targetPackage, ok := pme.packages[ref.Package] +func (pme *Explorer) FindPlatform(platformPackage, platformArchitecture string) *cores.Platform { + targetPackage, ok := pme.packages[platformPackage] if !ok { return nil } - platform, ok := targetPackage.Platforms[ref.PlatformArchitecture] + platform, ok := targetPackage.Platforms[platformArchitecture] if !ok { return nil } @@ -57,7 +57,7 @@ func (pme *Explorer) FindPlatform(ref *PlatformReference) *cores.Platform { // FindPlatformRelease returns the PlatformRelease matching the PlatformReference or nil if not found func (pme *Explorer) FindPlatformRelease(ref *PlatformReference) *cores.PlatformRelease { - platform := pme.FindPlatform(ref) + platform := pme.FindPlatform(ref.Package, ref.PlatformArchitecture) if platform == nil { return nil } diff --git a/arduino/cores/packagemanager/install_uninstall.go b/arduino/cores/packagemanager/install_uninstall.go index 73a75c7b00d..93ef233322e 100644 --- a/arduino/cores/packagemanager/install_uninstall.go +++ b/arduino/cores/packagemanager/install_uninstall.go @@ -44,7 +44,7 @@ func (pme *Explorer) DownloadAndInstallPlatformUpgrades( } // Search the latest version for all specified platforms - platform := pme.FindPlatform(platformRef) + platform := pme.FindPlatform(platformRef.Package, platformRef.PlatformArchitecture) if platform == nil { return nil, &arduino.PlatformNotFoundError{Platform: platformRef.String()} } diff --git a/arduino/cores/packagemanager/package_manager_test.go b/arduino/cores/packagemanager/package_manager_test.go index 7a6d8994004..e847d37ac31 100644 --- a/arduino/cores/packagemanager/package_manager_test.go +++ b/arduino/cores/packagemanager/package_manager_test.go @@ -387,10 +387,7 @@ func TestBoardOrdering(t *testing.T) { pme, release := pm.NewExplorer() defer release() - pl := pme.FindPlatform(&PlatformReference{ - Package: "arduino", - PlatformArchitecture: "avr", - }) + pl := pme.FindPlatform("arduino", "avr") require.NotNil(t, pl) plReleases := pl.GetAllInstalled() require.NotEmpty(t, plReleases) diff --git a/commands/core/uninstall.go b/commands/core/uninstall.go index 165b1fc16ea..da8cb786e5e 100644 --- a/commands/core/uninstall.go +++ b/commands/core/uninstall.go @@ -48,7 +48,7 @@ func platformUninstall(ctx context.Context, req *rpc.PlatformUninstallRequest, t PlatformArchitecture: req.Architecture, } if ref.PlatformVersion == nil { - platform := pme.FindPlatform(ref) + platform := pme.FindPlatform(ref.Package, ref.PlatformArchitecture) if platform == nil { return &arduino.PlatformNotFoundError{Platform: ref.String()} } diff --git a/commands/upload/upload.go b/commands/upload/upload.go index aa74023b0e3..40cbb0bb018 100644 --- a/commands/upload/upload.go +++ b/commands/upload/upload.go @@ -285,10 +285,7 @@ func runProgramAction(pme *packagemanager.Explorer, Property: fmt.Sprintf("%s.tool.%s", action, port.Protocol), // TODO: Can be done better, maybe inline getToolID(...) Value: uploadToolID} } else if len(split) == 2 { - p := pme.FindPlatform(&packagemanager.PlatformReference{ - Package: split[0], - PlatformArchitecture: boardPlatform.Platform.Architecture, - }) + p := pme.FindPlatform(split[0], boardPlatform.Platform.Architecture) if p == nil { return nil, &arduino.PlatformNotFoundError{Platform: split[0] + ":" + boardPlatform.Platform.Architecture} } diff --git a/internal/cli/compile/compile.go b/internal/cli/compile/compile.go index dfd5d4c70ba..fbb6ef6cb1a 100644 --- a/internal/cli/compile/compile.go +++ b/internal/cli/compile/compile.go @@ -25,7 +25,6 @@ import ( "strings" "github.com/arduino/arduino-cli/arduino" - "github.com/arduino/arduino-cli/arduino/cores/packagemanager" "github.com/arduino/arduino-cli/commands" "github.com/arduino/arduino-cli/commands/compile" "github.com/arduino/arduino-cli/commands/sketch" @@ -363,12 +362,8 @@ func runCompileCommand(cmd *cobra.Command, args []string) { panic(tr("Platform ID is not correct")) } - // FIXME: Here we should not access PackageManager... pme, release := commands.GetPackageManagerExplorer(compileRequest) - platform := pme.FindPlatform(&packagemanager.PlatformReference{ - Package: split[0], - PlatformArchitecture: split[1], - }) + platform := pme.FindPlatform(split[0], split[1]) release() if profileArg.String() == "" { diff --git a/internal/cli/upload/upload.go b/internal/cli/upload/upload.go index c7a5eb8866a..2217b0ccc1c 100644 --- a/internal/cli/upload/upload.go +++ b/internal/cli/upload/upload.go @@ -23,7 +23,6 @@ import ( "strings" "github.com/arduino/arduino-cli/arduino" - "github.com/arduino/arduino-cli/arduino/cores/packagemanager" "github.com/arduino/arduino-cli/commands" sk "github.com/arduino/arduino-cli/commands/sketch" "github.com/arduino/arduino-cli/commands/upload" @@ -130,12 +129,8 @@ func runUploadCommand(command *cobra.Command, args []string) { panic(tr("Platform ID is not correct")) } - // FIXME: Here we must not access package manager... pme, release := commands.GetPackageManagerExplorer(&rpc.UploadRequest{Instance: inst}) - platform := pme.FindPlatform(&packagemanager.PlatformReference{ - Package: split[0], - PlatformArchitecture: split[1], - }) + platform := pme.FindPlatform(split[0], split[1]) release() msg += "\n"