Skip to content

Commit 4c8f09c

Browse files
committed
Removed ctx.ToolsDirs
The ToolsDirs field has been replaced by BuiltInToolsDirs during the big refactoring in the arduino-builder repo. The intention was to remove ToolsDirs once done, but for some reasons I forgot to remove it. This commit completes the transition.
1 parent ad69500 commit 4c8f09c

File tree

3 files changed

+4
-27
lines changed

3 files changed

+4
-27
lines changed

Diff for: commands/compile/compile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func Compile(ctx context.Context, req *rpc.CompileReq, outStream, errStream io.W
9595
}
9696

9797
if toolsDir, err := config.BundleToolsDirectories(); err == nil {
98-
builderCtx.ToolsDirs = toolsDir
98+
builderCtx.BuiltInToolsDirs = toolsDir
9999
} else {
100100
return nil, fmt.Errorf("cannot get bundled tools directories: %s", err)
101101
}

Diff for: legacy/builder/tools_loader.go

+1-23
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
package builder
3131

3232
import (
33-
"fmt"
34-
"strings"
35-
3633
"github.com/arduino/arduino-cli/legacy/builder/types"
3734
"github.com/arduino/go-paths-helper"
3835
)
@@ -45,28 +42,9 @@ func (s *ToolsLoader) Run(ctx *types.Context) error {
4542
return nil
4643
}
4744

48-
folders := paths.NewPathList()
4945
builtinFolders := paths.NewPathList()
50-
51-
if ctx.BuiltInToolsDirs != nil || len(ctx.BuiltInLibrariesDirs) == 0 {
52-
folders = ctx.ToolsDirs
46+
if ctx.BuiltInToolsDirs != nil {
5347
builtinFolders = ctx.BuiltInToolsDirs
54-
} else {
55-
// Auto-detect built-in tools folders (for arduino-builder backward compatibility)
56-
// this is a deprecated feature and will be removed in the future
57-
builtinHardwareFolder, err := ctx.BuiltInLibrariesDirs[0].Join("..").Abs()
58-
59-
if err != nil {
60-
fmt.Println("Error detecting ")
61-
}
62-
63-
for _, folder := range ctx.ToolsDirs {
64-
if !strings.Contains(folder.String(), builtinHardwareFolder.String()) { // TODO: make a function to check for subfolders
65-
folders = append(folders, folder)
66-
} else {
67-
builtinFolders = append(builtinFolders, folder)
68-
}
69-
}
7048
}
7149

7250
pm := ctx.PackageManager

Diff for: legacy/builder/types/context.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ type ProgressStruct struct {
2424
type Context struct {
2525
// Build options
2626
HardwareDirs paths.PathList
27-
ToolsDirs paths.PathList
2827
BuiltInToolsDirs paths.PathList
2928
BuiltInLibrariesDirs paths.PathList
3029
OtherLibrariesDirs paths.PathList
@@ -122,7 +121,7 @@ type Context struct {
122121
func (ctx *Context) ExtractBuildOptions() *properties.Map {
123122
opts := properties.NewMap()
124123
opts.Set("hardwareFolders", strings.Join(ctx.HardwareDirs.AsStrings(), ","))
125-
opts.Set("toolsFolders", strings.Join(ctx.ToolsDirs.AsStrings(), ","))
124+
opts.Set("builtInToolsFolders", strings.Join(ctx.BuiltInToolsDirs.AsStrings(), ","))
126125
opts.Set("builtInLibrariesFolders", strings.Join(ctx.BuiltInLibrariesDirs.AsStrings(), ","))
127126
opts.Set("otherLibrariesFolders", strings.Join(ctx.OtherLibrariesDirs.AsStrings(), ","))
128127
opts.SetPath("sketchLocation", ctx.SketchLocation)
@@ -146,7 +145,7 @@ func (ctx *Context) ExtractBuildOptions() *properties.Map {
146145

147146
func (ctx *Context) InjectBuildOptions(opts *properties.Map) {
148147
ctx.HardwareDirs = paths.NewPathList(strings.Split(opts.Get("hardwareFolders"), ",")...)
149-
ctx.ToolsDirs = paths.NewPathList(strings.Split(opts.Get("toolsFolders"), ",")...)
148+
ctx.BuiltInToolsDirs = paths.NewPathList(strings.Split(opts.Get("builtInToolsFolders"), ",")...)
150149
ctx.BuiltInLibrariesDirs = paths.NewPathList(strings.Split(opts.Get("builtInLibrariesFolders"), ",")...)
151150
ctx.OtherLibrariesDirs = paths.NewPathList(strings.Split(opts.Get("otherLibrariesFolders"), ",")...)
152151
ctx.SketchLocation = opts.GetPath("sketchLocation")

0 commit comments

Comments
 (0)