From d7e28e75f7e1ef9ae852514dca975eedd5b72b0c Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Mon, 14 Aug 2023 14:58:51 +0200 Subject: [PATCH] Load profiles when LoadSketch is called --- commands/sketch/load.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/commands/sketch/load.go b/commands/sketch/load.go index 2125c0116c7..7fb33a0fca9 100644 --- a/commands/sketch/load.go +++ b/commands/sketch/load.go @@ -48,6 +48,43 @@ func LoadSketch(ctx context.Context, req *rpc.LoadSketchRequest) (*rpc.LoadSketc } defaultPort, defaultProtocol := sk.GetDefaultPortAddressAndProtocol() + + profiles := make([](*rpc.SketchProfile), len(sk.Project.Profiles)) + for i, profile := range sk.Project.Profiles { + platforms := []string{} + libraries := []string{} + for _, platform := range profile.Platforms { + platforms = append(platforms, platform.String()) + } + for _, library := range profile.Libraries { + libraries = append(libraries, library.String()) + } + profiles[i] = &rpc.SketchProfile{ + Name: profile.Name, + Fqbn: profile.FQBN, + RequiredPlatforms: platforms, + RequiredLibraries: libraries, + } + } + + defaultProfileResp := &rpc.SketchProfile{} + defaultProfile := sk.GetProfile(sk.Project.DefaultProfile) + if defaultProfile != nil { + platforms := []string{} + libraries := []string{} + for _, platform := range defaultProfile.Platforms { + platforms = append(platforms, platform.String()) + } + for _, library := range defaultProfile.Libraries { + libraries = append(libraries, library.String()) + } + + defaultProfileResp.Name = defaultProfile.Name + defaultProfileResp.Fqbn = defaultProfile.FQBN + defaultProfileResp.RequiredLibraries = libraries + defaultProfileResp.RequiredPlatforms = platforms + } + return &rpc.LoadSketchResponse{ MainFile: sk.MainFile.String(), LocationPath: sk.FullPath.String(), @@ -57,5 +94,7 @@ func LoadSketch(ctx context.Context, req *rpc.LoadSketchRequest) (*rpc.LoadSketc DefaultFqbn: sk.GetDefaultFQBN(), DefaultPort: defaultPort, DefaultProtocol: defaultProtocol, + Profiles: profiles, + DefaultProfile: defaultProfileResp, }, nil }