Skip to content

Commit 8050841

Browse files
committed
Bundled libraries configuration is now considere a single directory
1 parent 7a34b9d commit 8050841

12 files changed

+54
-58
lines changed

Diff for: commands/instances.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,7 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
390390
if profile == nil {
391391
// Add directories of libraries bundled with IDE
392392
if bundledLibsDir := configuration.IDEBuiltinLibrariesDir(configuration.Settings); bundledLibsDir != nil {
393-
for _, d := range bundledLibsDir {
394-
lm.AddLibrariesDir(d, libraries.IDEBuiltIn)
395-
}
393+
lm.AddLibrariesDir(bundledLibsDir, libraries.IDEBuiltIn)
396394
}
397395

398396
// Add libraries directory from config file

Diff for: configuration/directories.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ func BuiltinToolsDirectories(settings *viper.Viper) paths.PathList {
4747
return paths.NewPathList(settings.GetStringSlice("directories.builtin.Tools")...)
4848
}
4949

50-
// IDEBuiltinLibrariesDir returns the IDE-bundled libraries paths. Usually
51-
// one of these directories is present in the Arduino IDE.
52-
func IDEBuiltinLibrariesDir(settings *viper.Viper) paths.PathList {
53-
return paths.NewPathList(Settings.GetStringSlice("directories.builtin.Libraries")...)
50+
// IDEBuiltinLibrariesDir returns the IDE-bundled libraries path. Usually
51+
// this directory is present in the Arduino IDE.
52+
func IDEBuiltinLibrariesDir(settings *viper.Viper) *paths.Path {
53+
return paths.New(Settings.GetString("directories.builtin.Libraries"))
5454
}
5555

5656
// LibrariesDir returns the full path to the user directory containing

Diff for: legacy/builder/libraries_loader.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ func (s *LibrariesLoader) Run(ctx *types.Context) error {
3939
if err := builtInLibrariesFolders.ToAbs(); err != nil {
4040
return errors.WithStack(err)
4141
}
42-
for _, folder := range builtInLibrariesFolders {
43-
lm.AddLibrariesDir(folder, libraries.IDEBuiltIn)
44-
}
42+
lm.AddLibrariesDir(builtInLibrariesFolders, libraries.IDEBuiltIn)
4543

4644
if ctx.ActualPlatform != ctx.TargetPlatform {
4745
lm.AddPlatformReleaseLibrariesDir(ctx.ActualPlatform, libraries.ReferencedPlatformBuiltIn)

Diff for: legacy/builder/test/builder_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func prepareBuilderTestContext(t *testing.T, sketchPath *paths.Path, fqbn string
3737
FQBN: parseFQBN(t, fqbn),
3838
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
3939
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
40-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
40+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
4141
OtherLibrariesDirs: paths.NewPathList("libraries"),
4242
ArduinoAPIVersion: "10600",
4343
Verbose: false,

Diff for: legacy/builder/test/ctags_runner_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestCTagsRunner(t *testing.T) {
3434
ctx := &types.Context{
3535
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
3636
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
37-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
37+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
3838
OtherLibrariesDirs: paths.NewPathList("libraries"),
3939
SketchLocation: sketchLocation,
4040
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
@@ -84,7 +84,7 @@ func TestCTagsRunnerSketchWithClass(t *testing.T) {
8484
ctx := &types.Context{
8585
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
8686
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
87-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
87+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
8888
OtherLibrariesDirs: paths.NewPathList("libraries"),
8989
SketchLocation: sketchLocation,
9090
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
@@ -132,7 +132,7 @@ func TestCTagsRunnerSketchWithTypename(t *testing.T) {
132132
ctx := &types.Context{
133133
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
134134
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
135-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
135+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
136136
OtherLibrariesDirs: paths.NewPathList("libraries"),
137137
SketchLocation: sketchLocation,
138138
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
@@ -179,7 +179,7 @@ func TestCTagsRunnerSketchWithNamespace(t *testing.T) {
179179
ctx := &types.Context{
180180
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
181181
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
182-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
182+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
183183
OtherLibrariesDirs: paths.NewPathList("libraries"),
184184
SketchLocation: sketchLocation,
185185
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
@@ -225,7 +225,7 @@ func TestCTagsRunnerSketchWithTemplates(t *testing.T) {
225225
ctx := &types.Context{
226226
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
227227
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
228-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
228+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
229229
OtherLibrariesDirs: paths.NewPathList("libraries"),
230230
SketchLocation: sketchLocation,
231231
FQBN: parseFQBN(t, "arduino:avr:leonardo"),

Diff for: legacy/builder/test/includes_to_include_folders_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestIncludesToIncludeFolders(t *testing.T) {
3232
ctx := &types.Context{
3333
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
3434
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
35-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
35+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
3636
OtherLibrariesDirs: paths.NewPathList("libraries"),
3737
SketchLocation: paths.New("downloaded_libraries", "Bridge", "examples", "Bridge", "Bridge.ino"),
3838
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
@@ -68,7 +68,7 @@ func TestIncludesToIncludeFoldersSketchWithIfDef(t *testing.T) {
6868
ctx := &types.Context{
6969
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
7070
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
71-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
71+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
7272
OtherLibrariesDirs: paths.NewPathList("libraries"),
7373
SketchLocation: paths.New("SketchWithIfDef", "SketchWithIfDef.ino"),
7474
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
@@ -103,7 +103,7 @@ func TestIncludesToIncludeFoldersIRremoteLibrary(t *testing.T) {
103103
ctx := &types.Context{
104104
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
105105
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
106-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
106+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
107107
OtherLibrariesDirs: paths.NewPathList("libraries"),
108108
SketchLocation: paths.New("sketch9", "sketch9.ino"),
109109
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
@@ -141,7 +141,7 @@ func TestIncludesToIncludeFoldersANewLibrary(t *testing.T) {
141141
ctx := &types.Context{
142142
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
143143
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
144-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
144+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
145145
OtherLibrariesDirs: paths.NewPathList("libraries"),
146146
SketchLocation: paths.New("sketch10", "sketch10.ino"),
147147
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
@@ -176,7 +176,7 @@ func TestIncludesToIncludeFoldersDuplicateLibs(t *testing.T) {
176176
ctx := &types.Context{
177177
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "user_hardware"),
178178
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
179-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
179+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
180180
SketchLocation: paths.New("user_hardware", "my_avr_platform", "avr", "libraries", "SPI", "examples", "BarometricPressureSensor", "BarometricPressureSensor.ino"),
181181
FQBN: parseFQBN(t, "my_avr_platform:avr:custom_yun"),
182182
ArduinoAPIVersion: "10600",
@@ -213,7 +213,7 @@ func TestIncludesToIncludeFoldersDuplicateLibsWithConflictingLibsOutsideOfPlatfo
213213
ctx := &types.Context{
214214
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "user_hardware"),
215215
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
216-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
216+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
217217
OtherLibrariesDirs: paths.NewPathList("libraries"),
218218
SketchLocation: paths.New("user_hardware", "my_avr_platform", "avr", "libraries", "SPI", "examples", "BarometricPressureSensor", "BarometricPressureSensor.ino"),
219219
FQBN: parseFQBN(t, "my_avr_platform:avr:custom_yun"),
@@ -251,7 +251,7 @@ func TestIncludesToIncludeFoldersDuplicateLibs2(t *testing.T) {
251251
ctx := &types.Context{
252252
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "downloaded_board_manager_stuff"),
253253
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
254-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
254+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
255255
OtherLibrariesDirs: paths.NewPathList("libraries"),
256256
SketchLocation: paths.New("sketch_usbhost", "sketch_usbhost.ino"),
257257
FQBN: parseFQBN(t, "arduino:samd:arduino_zero_native"),
@@ -289,7 +289,7 @@ func TestIncludesToIncludeFoldersSubfolders(t *testing.T) {
289289
ctx := &types.Context{
290290
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
291291
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
292-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
292+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
293293
OtherLibrariesDirs: paths.NewPathList("libraries"),
294294
SketchLocation: paths.New("sketch_with_subfolders", "sketch_with_subfolders.ino"),
295295
FQBN: parseFQBN(t, "arduino:avr:leonardo"),

Diff for: legacy/builder/test/libraries_loader_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestLoadLibrariesAVR(t *testing.T) {
4242

4343
ctx := &types.Context{
4444
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
45-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
45+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
4646
OtherLibrariesDirs: paths.NewPathList("libraries"),
4747
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
4848
}
@@ -152,7 +152,7 @@ func TestLoadLibrariesSAM(t *testing.T) {
152152

153153
ctx := &types.Context{
154154
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
155-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
155+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
156156
OtherLibrariesDirs: paths.NewPathList("libraries"),
157157
FQBN: parseFQBN(t, "arduino:sam:arduino_due_x_dbg"),
158158
}
@@ -235,7 +235,7 @@ func TestLoadLibrariesAVRNoDuplicateLibrariesFolders(t *testing.T) {
235235

236236
ctx := &types.Context{
237237
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
238-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
238+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
239239
OtherLibrariesDirs: paths.NewPathList("libraries", filepath.Join("downloaded_hardware", "arduino", "avr", "libraries")),
240240
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
241241
}
@@ -264,7 +264,7 @@ func TestLoadLibrariesMyAVRPlatform(t *testing.T) {
264264

265265
ctx := &types.Context{
266266
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "user_hardware", "downloaded_hardware"),
267-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
267+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
268268
OtherLibrariesDirs: paths.NewPathList("libraries", filepath.Join("downloaded_hardware", "arduino", "avr", "libraries")),
269269
FQBN: parseFQBN(t, "my_avr_platform:avr:custom_yun"),
270270
}

Diff for: legacy/builder/test/merge_sketch_with_bootloader_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestMergeSketchWithBootloader(t *testing.T) {
3434
ctx := &types.Context{
3535
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
3636
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
37-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
37+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
3838
OtherLibrariesDirs: paths.NewPathList("libraries"),
3939
SketchLocation: paths.New("sketch1", "sketch1.ino"),
4040
FQBN: parseFQBN(t, "arduino:avr:uno"),
@@ -104,7 +104,7 @@ func TestMergeSketchWithBootloaderSketchInBuildPath(t *testing.T) {
104104
ctx := &types.Context{
105105
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
106106
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
107-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
107+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
108108
OtherLibrariesDirs: paths.NewPathList("libraries"),
109109
SketchLocation: paths.New("sketch1", "sketch1.ino"),
110110
FQBN: parseFQBN(t, "arduino:avr:uno"),
@@ -175,7 +175,7 @@ func TestMergeSketchWithBootloaderWhenNoBootloaderAvailable(t *testing.T) {
175175
ctx := &types.Context{
176176
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
177177
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
178-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
178+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
179179
OtherLibrariesDirs: paths.NewPathList("libraries"),
180180
SketchLocation: paths.New("sketch1", "sketch1.ino"),
181181
FQBN: parseFQBN(t, "arduino:avr:uno"),
@@ -213,7 +213,7 @@ func TestMergeSketchWithBootloaderPathIsParameterized(t *testing.T) {
213213
ctx := &types.Context{
214214
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "user_hardware"),
215215
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
216-
BuiltInLibrariesDirs: paths.NewPathList("downloaded_libraries"),
216+
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
217217
OtherLibrariesDirs: paths.NewPathList("libraries"),
218218
SketchLocation: paths.New("sketch1", "sketch1.ino"),
219219
FQBN: parseFQBN(t, "my_avr_platform:avr:mymega:cpu=atmega2560"),

0 commit comments

Comments
 (0)