diff --git a/arduino/cores/cores.go b/arduino/cores/cores.go index ea229d98244..67f0c60ba3a 100644 --- a/arduino/cores/cores.go +++ b/arduino/cores/cores.go @@ -28,11 +28,12 @@ import ( // Platform represents a platform package. type Platform struct { - Architecture string // The name of the architecture of this package. - Name string - Category string - Releases map[string]*PlatformRelease // The Releases of this platform, labeled by version. - Package *Package `json:"-"` + Architecture string // The name of the architecture of this package. + Name string + Category string + Releases map[string]*PlatformRelease // The Releases of this platform, labeled by version. + Package *Package `json:"-"` + ManuallyInstalled bool // true if the Platform has been installed without the CLI } // PlatformReleaseHelp represents the help URL for this Platform release diff --git a/arduino/cores/packagemanager/loader.go b/arduino/cores/packagemanager/loader.go index 2b4133e7cf5..b7aa88f30e1 100644 --- a/arduino/cores/packagemanager/loader.go +++ b/arduino/cores/packagemanager/loader.go @@ -166,18 +166,15 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir return fmt.Errorf("looking for boards.txt in %s: %s", possibleBoardTxtPath, err) } else if exist { - - // case: ARCHITECTURE/boards.txt - // this is the general case for unversioned Platform - version := semver.MustParse("") - - // FIXME: this check is duplicated, find a better way to handle this - if exist, err := platformPath.Join("boards.txt").ExistCheck(); err != nil { - return fmt.Errorf("opening boards.txt: %s", err) - } else if !exist { - continue + platformTxtPath := platformPath.Join("platform.txt") + platformProperties, err := properties.SafeLoad(platformTxtPath.String()) + if err != nil { + return fmt.Errorf("loading platform.txt: %w", err) } + platformName := platformProperties.Get("name") + version := semver.MustParse(platformProperties.Get("version")) + // check if package_bundled_index.json exists isIDEBundled := false packageBundledIndexPath := packageDir.Parent().Join("package_index_bundled.json") @@ -210,6 +207,12 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir } platform := targetPackage.GetOrCreatePlatform(architecture) + if platform.Name == "" { + platform.Name = platformName + } + if !isIDEBundled { + platform.ManuallyInstalled = true + } release := platform.GetOrCreateRelease(version) release.IsIDEBundled = isIDEBundled if isIDEBundled { diff --git a/cli/core/list.go b/cli/core/list.go index f6012f58daf..bf49f7eea0d 100644 --- a/cli/core/list.go +++ b/cli/core/list.go @@ -39,11 +39,13 @@ func initListCommand() *cobra.Command { Run: runListCommand, } listCommand.Flags().BoolVar(&listFlags.updatableOnly, "updatable", false, "List updatable platforms.") + listCommand.Flags().BoolVar(&listFlags.all, "all", false, "If set return all installable and installed cores, including manually installed.") return listCommand } var listFlags struct { updatableOnly bool + all bool } func runListCommand(cmd *cobra.Command, args []string) { @@ -55,7 +57,7 @@ func runListCommand(cmd *cobra.Command, args []string) { logrus.Info("Executing `arduino core list`") - platforms, err := core.GetPlatforms(inst.Id, listFlags.updatableOnly) + platforms, err := core.GetPlatforms(inst.Id, listFlags.updatableOnly, listFlags.all) if err != nil { feedback.Errorf("Error listing platforms: %v", err) os.Exit(errorcodes.ErrGeneric) diff --git a/cli/core/upgrade.go b/cli/core/upgrade.go index 2e25f5d6ea8..e20dcd16b23 100644 --- a/cli/core/upgrade.go +++ b/cli/core/upgrade.go @@ -57,7 +57,7 @@ func runUpgradeCommand(cmd *cobra.Command, args []string) { // if no platform was passed, upgrade allthethings if len(args) == 0 { - targets, err := core.GetPlatforms(inst.Id, true) + targets, err := core.GetPlatforms(inst.Id, true, false) if err != nil { feedback.Errorf("Error retrieving core list: %v", err) os.Exit(errorcodes.ErrGeneric) diff --git a/commands/core.go b/commands/core.go index 1467e6453ae..8003ebd1978 100644 --- a/commands/core.go +++ b/commands/core.go @@ -51,13 +51,14 @@ func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.Platform } result := &rpc.Platform{ - ID: platformRelease.Platform.String(), - Name: platformRelease.Platform.Name, - Maintainer: platformRelease.Platform.Package.Maintainer, - Website: platformRelease.Platform.Package.WebsiteURL, - Email: platformRelease.Platform.Package.Email, - Boards: boards, - Latest: platformRelease.Version.String(), + ID: platformRelease.Platform.String(), + Name: platformRelease.Platform.Name, + Maintainer: platformRelease.Platform.Package.Maintainer, + Website: platformRelease.Platform.Package.WebsiteURL, + Email: platformRelease.Platform.Package.Email, + Boards: boards, + Latest: platformRelease.Version.String(), + ManuallyInstalled: platformRelease.Platform.ManuallyInstalled, } return result diff --git a/commands/core/list.go b/commands/core/list.go index 3444bebc522..f634d4cacd9 100644 --- a/commands/core/list.go +++ b/commands/core/list.go @@ -23,7 +23,7 @@ import ( // GetPlatforms returns a list of installed platforms, optionally filtered by // those requiring an update. -func GetPlatforms(instanceID int32, updatableOnly bool) ([]*cores.PlatformRelease, error) { +func GetPlatforms(instanceID int32, updatableOnly, all bool) ([]*cores.PlatformRelease, error) { i := commands.GetInstance(instanceID) if i == nil { return nil, errors.Errorf("unable to find an instance with ID: %d", instanceID) @@ -34,16 +34,24 @@ func GetPlatforms(instanceID int32, updatableOnly bool) ([]*cores.PlatformReleas return nil, errors.New("invalid instance") } + if updatableOnly && all { + return nil, errors.New("can't use both updatableOnly and all flags at the same time") + } + res := []*cores.PlatformRelease{} for _, targetPackage := range packageManager.Packages { for _, platform := range targetPackage.Platforms { - if platformRelease := packageManager.GetInstalledPlatformRelease(platform); platformRelease != nil { + platformRelease := packageManager.GetInstalledPlatformRelease(platform) + if all { + res = append(res, platform.GetLatestRelease()) + continue + } + if platformRelease != nil { if updatableOnly { if latest := platform.GetLatestRelease(); latest == nil || latest == platformRelease { continue } } - res = append(res, platformRelease) } } diff --git a/commands/core/search.go b/commands/core/search.go index bb9a218de39..c60cc239efc 100644 --- a/commands/core/search.go +++ b/commands/core/search.go @@ -48,7 +48,10 @@ func PlatformSearch(instanceID int32, searchArgs string, allVersions bool) (*rpc for _, targetPackage := range pm.Packages { for _, platform := range targetPackage.Platforms { // discard invalid platforms - if platform == nil || platform.Name == "" { + // Users can install platforms manually in the Sketchbook hardware folder, + // the core search command must operate only on platforms installed through + // the PlatformManager, thus we skip the manually installed ones. + if platform == nil || platform.Name == "" || platform.ManuallyInstalled { continue } diff --git a/commands/daemon/daemon.go b/commands/daemon/daemon.go index c18308da050..cdeed63934c 100644 --- a/commands/daemon/daemon.go +++ b/commands/daemon/daemon.go @@ -264,7 +264,7 @@ func (s *ArduinoCoreServerImpl) PlatformSearch(ctx context.Context, req *rpc.Pla // PlatformList FIXMEDOC func (s *ArduinoCoreServerImpl) PlatformList(ctx context.Context, req *rpc.PlatformListReq) (*rpc.PlatformListResp, error) { - platforms, err := core.GetPlatforms(req.Instance.Id, req.UpdatableOnly) + platforms, err := core.GetPlatforms(req.Instance.Id, req.UpdatableOnly, req.All) if err != nil { return nil, err } diff --git a/rpc/commands/core.pb.go b/rpc/commands/core.pb.go index b50430ed524..2c26ab04f2e 100644 --- a/rpc/commands/core.pb.go +++ b/rpc/commands/core.pb.go @@ -674,6 +674,10 @@ type PlatformListReq struct { // Set to true to only list platforms which have a newer version available // than the one currently installed. UpdatableOnly bool `protobuf:"varint,2,opt,name=updatable_only,json=updatableOnly,proto3" json:"updatable_only,omitempty"` + // Set to true to list platforms installed manually in the user' sketchbook + // hardware folder, installed with the PlatformManager through the CLI or IDE + // and that are available to install + All bool `protobuf:"varint,3,opt,name=all,proto3" json:"all,omitempty"` } func (x *PlatformListReq) Reset() { @@ -722,6 +726,13 @@ func (x *PlatformListReq) GetUpdatableOnly() bool { return false } +func (x *PlatformListReq) GetAll() bool { + if x != nil { + return x.All + } + return false +} + type PlatformListResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -795,6 +806,9 @@ type Platform struct { // not installed, this is an arbitrary list of board names provided by the // platform author for display and may not match boards.txt. Boards []*Board `protobuf:"bytes,8,rep,name=Boards,proto3" json:"Boards,omitempty"` + // If true this Platform has been installed manually in the user' sketchbook + // hardware folder + ManuallyInstalled bool `protobuf:"varint,9,opt,name=ManuallyInstalled,proto3" json:"ManuallyInstalled,omitempty"` } func (x *Platform) Reset() { @@ -885,6 +899,13 @@ func (x *Platform) GetBoards() []*Board { return nil } +func (x *Platform) GetManuallyInstalled() bool { + if x != nil { + return x.ManuallyInstalled + } + return false +} + type Board struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1049,42 +1070,46 @@ var file_commands_core_proto_rawDesc = []byte{ 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x0c, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x4f, - 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, 0x77, 0x0a, 0x0f, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, - 0x6d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x3d, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x63, 0x2e, - 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x69, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x75, 0x70, 0x64, 0x61, 0x74, - 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x0d, 0x75, 0x70, 0x64, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x22, 0x64, - 0x0a, 0x10, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x12, 0x50, 0x0a, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x5f, - 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, - 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, - 0x6d, 0x52, 0x11, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, 0x6c, 0x61, 0x74, - 0x66, 0x6f, 0x72, 0x6d, 0x22, 0xec, 0x01, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, - 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, - 0x44, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x12, - 0x16, 0x0a, 0x06, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x06, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x4d, - 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x4d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x57, - 0x65, 0x62, 0x73, 0x69, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x57, 0x65, - 0x62, 0x73, 0x69, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x36, 0x0a, 0x06, 0x42, - 0x6f, 0x61, 0x72, 0x64, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x63, + 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, 0x89, 0x01, 0x0a, 0x0f, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, + 0x72, 0x6d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x3d, 0x0a, 0x08, 0x69, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x52, 0x06, 0x42, 0x6f, 0x61, - 0x72, 0x64, 0x73, 0x22, 0x2f, 0x0a, 0x05, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x66, 0x71, 0x62, 0x6e, 0x42, 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, - 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, + 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x75, 0x70, 0x64, 0x61, + 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x0d, 0x75, 0x70, 0x64, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x61, 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x61, 0x6c, + 0x6c, 0x22, 0x64, 0x0a, 0x10, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x50, 0x0a, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, + 0x65, 0x64, 0x5f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, + 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x50, 0x6c, 0x61, 0x74, + 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x11, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, + 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x22, 0x9a, 0x02, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, + 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x49, 0x44, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, + 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, + 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1e, + 0x0a, 0x0a, 0x4d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x4d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x18, + 0x0a, 0x07, 0x57, 0x65, 0x62, 0x73, 0x69, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x57, 0x65, 0x62, 0x73, 0x69, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, 0x61, 0x69, + 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x36, + 0x0a, 0x06, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, + 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x52, 0x06, + 0x42, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x12, 0x2c, 0x0a, 0x11, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, + 0x6c, 0x79, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x11, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x6c, 0x79, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6c, 0x6c, 0x65, 0x64, 0x22, 0x2f, 0x0a, 0x05, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x66, 0x71, 0x62, 0x6e, 0x42, 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, + 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/rpc/commands/core.proto b/rpc/commands/core.proto index 030e38be92b..92259368d09 100644 --- a/rpc/commands/core.proto +++ b/rpc/commands/core.proto @@ -109,6 +109,10 @@ message PlatformListReq { // Set to true to only list platforms which have a newer version available // than the one currently installed. bool updatable_only = 2; + // Set to true to list platforms installed manually in the user' sketchbook + // hardware folder, installed with the PlatformManager through the CLI or IDE + // and that are available to install + bool all = 3; } message PlatformListResp { @@ -137,6 +141,9 @@ message Platform { // not installed, this is an arbitrary list of board names provided by the // platform author for display and may not match boards.txt. repeated Board Boards = 8; + // If true this Platform has been installed manually in the user' sketchbook + // hardware folder + bool ManuallyInstalled = 9; } message Board { diff --git a/rpc/settings/settings.pb.go b/rpc/settings/settings.pb.go index 2ae20db78c4..7242b11d8d1 100644 --- a/rpc/settings/settings.pb.go +++ b/rpc/settings/settings.pb.go @@ -636,7 +636,7 @@ type SettingsClient interface { GetValue(ctx context.Context, in *GetValueRequest, opts ...grpc.CallOption) (*Value, error) // Set the value of a specific setting. SetValue(ctx context.Context, in *Value, opts ...grpc.CallOption) (*SetValueResponse, error) - // Writes to file current in memory settings + // Writes to file settings currently stored in memory Write(ctx context.Context, in *WriteRequest, opts ...grpc.CallOption) (*WriteResponse, error) } @@ -703,7 +703,7 @@ type SettingsServer interface { GetValue(context.Context, *GetValueRequest) (*Value, error) // Set the value of a specific setting. SetValue(context.Context, *Value) (*SetValueResponse, error) - // Writes to file current in memory settings + // Writes to file settings currently stored in memory Write(context.Context, *WriteRequest) (*WriteResponse, error) } diff --git a/test/test_core.py b/test/test_core.py index e2813ddad62..9e5ba5818ca 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -18,6 +18,7 @@ import simplejson as json import tempfile import hashlib +from git import Repo from pathlib import Path @@ -363,3 +364,62 @@ def test_core_update_with_local_url(run_command): res = run_command(f'core update-index --additional-urls="file://{test_index}"') assert res.ok assert "Updating index: test_index.json downloaded" in res.stdout + + +def test_core_search_manually_installed_cores_not_printed(run_command, data_dir): + assert run_command("core update-index") + + # Verifies only cores in board manager are shown + res = run_command("core search --format json") + assert res.ok + cores = json.loads(res.stdout) + assert len(cores) == 17 + + # Manually installs a core in sketchbooks hardware folder + git_url = "https://github.com/arduino/ArduinoCore-avr.git" + repo_dir = Path(data_dir, "hardware", "arduino-beta-development", "avr") + assert Repo.clone_from(git_url, repo_dir, multi_options=["-b 1.8.3"]) + + # Verifies manually installed core is not shown + res = run_command("core search --format json") + assert res.ok + cores = json.loads(res.stdout) + assert len(cores) == 17 + mapped = {core["ID"]: core for core in cores} + core_id = "arduino-beta-development:avr" + assert core_id not in mapped + + +def test_core_list_all_manually_installed_core(run_command, data_dir): + assert run_command("core update-index") + + # Verifies only cores in board manager are shown + res = run_command("core list --all --format json") + assert res.ok + cores = json.loads(res.stdout) + assert len(cores) == 17 + + # Manually installs a core in sketchbooks hardware folder + git_url = "https://github.com/arduino/ArduinoCore-avr.git" + repo_dir = Path(data_dir, "hardware", "arduino-beta-development", "avr") + assert Repo.clone_from(git_url, repo_dir, multi_options=["-b 1.8.3"]) + + # Verifies manually installed core is shown + res = run_command("core list --all --format json") + assert res.ok + cores = json.loads(res.stdout) + assert len(cores) == 18 + mapped = {core["ID"]: core for core in cores} + expected_core_id = "arduino-beta-development:avr" + assert expected_core_id in mapped + assert "Arduino AVR Boards" == mapped[expected_core_id]["Name"] + assert "1.8.3" == mapped[expected_core_id]["Latest"] + + +def test_core_list_updatable_all_flags(run_command, data_dir): + assert run_command("core update-index") + + # Verifies using both --all and --updatable flags fails + res = run_command("core list --all --updatable --format json") + assert res.failed + assert "can't use both updatableOnly and all flags at the same time" in res.stderr