Skip to content

Commit be3592e

Browse files
committed
Change commands to get CoreInstance settings
1 parent 7dacb8f commit be3592e

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

commands/compile/compile.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,15 @@ var tr = i18n.Tr
4848
// Compile FIXMEDOC
4949
func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream io.Writer, progressCB commands.TaskProgressCB, debug bool) (r *rpc.CompileResponse, e error) {
5050

51+
instance := commands.GetInstance(req.GetInstance().GetId())
52+
if instance == nil {
53+
return nil, &arduino.InvalidInstanceError{}
54+
}
55+
5156
// There is a binding between the export binaries setting and the CLI flag to explicitly set it,
5257
// since we want this binding to work also for the gRPC interface we must read it here in this
5358
// package instead of the cli/compile one, otherwise we'd lose the binding.
54-
exportBinaries := configuration.Settings.GetBool("sketch.always_export_binaries")
59+
exportBinaries := instance.Settings.GetBool("sketch.always_export_binaries")
5560
// If we'd just read the binding in any case, even if the request sets the export binaries setting,
5661
// the settings value would always overwrite the request one and it wouldn't have any effect
5762
// setting it for individual requests. To solve this we use a wrapper.BoolValue to handle
@@ -135,11 +140,11 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
135140
builderCtx.ProgressCB = progressCB
136141

137142
// FIXME: This will be redundant when arduino-builder will be part of the cli
138-
builderCtx.HardwareDirs = configuration.HardwareDirectories(configuration.Settings)
139-
builderCtx.BuiltInToolsDirs = configuration.BundleToolsDirectories(configuration.Settings)
143+
builderCtx.HardwareDirs = configuration.HardwareDirectories(instance.Settings)
144+
builderCtx.BuiltInToolsDirs = configuration.BundleToolsDirectories(instance.Settings)
140145

141146
builderCtx.OtherLibrariesDirs = paths.NewPathList(req.GetLibraries()...)
142-
builderCtx.OtherLibrariesDirs.Add(configuration.LibrariesDir(configuration.Settings))
147+
builderCtx.OtherLibrariesDirs.Add(configuration.LibrariesDir(instance.Settings))
143148

144149
builderCtx.LibraryDirs = paths.NewPathList(req.Library...)
145150

@@ -187,7 +192,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
187192
builderCtx.ArduinoAPIVersion = "10607"
188193

189194
// Check if Arduino IDE is installed and get it's libraries location.
190-
dataDir := paths.New(configuration.Settings.GetString("directories.Data"))
195+
dataDir := paths.New(instance.Settings.GetString("directories.Data"))
191196
preferencesTxt := dataDir.Join("preferences.txt")
192197
ideProperties, err := properties.LoadFromPath(preferencesTxt)
193198
if err == nil {

commands/lib/uninstall.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
// LibraryUninstall FIXMEDOC
2727
func LibraryUninstall(ctx context.Context, req *rpc.LibraryUninstallRequest, taskCB commands.TaskProgressCB) error {
2828
lm := commands.GetLibraryManager(req.GetInstance().GetId())
29-
ref, err := createLibIndexReference(lm, req)
29+
ref, err := createLibIndexReference(req)
3030
if err != nil {
3131
return &arduino.InvalidLibraryError{Cause: err}
3232
}

commands/lib/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type libraryReferencer interface {
2727
GetName() string
2828
}
2929

30-
func createLibIndexReference(lm *librariesmanager.LibrariesManager, req libraryReferencer) (*librariesindex.Reference, error) {
30+
func createLibIndexReference(req libraryReferencer) (*librariesindex.Reference, error) {
3131
version, err := commands.ParseVersion(req)
3232
if err != nil {
3333
return nil, &arduino.InvalidVersionError{Cause: err}
@@ -37,7 +37,7 @@ func createLibIndexReference(lm *librariesmanager.LibrariesManager, req libraryR
3737
}
3838

3939
func findLibraryIndexRelease(lm *librariesmanager.LibrariesManager, req libraryReferencer) (*librariesindex.Release, error) {
40-
ref, err := createLibIndexReference(lm, req)
40+
ref, err := createLibIndexReference(req)
4141
if err != nil {
4242
return nil, err
4343
}

commands/sketch/new.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020

2121
"github.com/arduino/arduino-cli/arduino"
2222
"github.com/arduino/arduino-cli/arduino/globals"
23-
"github.com/arduino/arduino-cli/configuration"
23+
"github.com/arduino/arduino-cli/commands"
2424
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2525
paths "github.com/arduino/go-paths-helper"
2626
)
@@ -39,7 +39,8 @@ func NewSketch(ctx context.Context, req *rpc.NewSketchRequest) (*rpc.NewSketchRe
3939
if len(req.SketchDir) > 0 {
4040
sketchesDir = req.SketchDir
4141
} else {
42-
sketchesDir = configuration.Settings.GetString("directories.User")
42+
instance := commands.GetInstance(req.Instance.Id)
43+
sketchesDir = instance.Settings.GetString("directories.User")
4344
}
4445
sketchDirPath := paths.New(sketchesDir).Join(req.SketchName)
4546
if err := sketchDirPath.MkdirAll(); err != nil {

0 commit comments

Comments
 (0)