Skip to content

Commit

Permalink
Load profiles when LoadSketch is called
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoPologruto committed Aug 14, 2023
1 parent a6dc8b5 commit 740cf1b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions commands/sketch/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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
}

0 comments on commit 740cf1b

Please sign in to comment.