Skip to content

Commit e779f4d

Browse files
committed
Renamed variables for clarity
1 parent d3692b6 commit e779f4d

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

internal/arduino/builder/builder.go

+15-11
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,12 @@ func NewBuilder(
143143
}
144144
if sk != nil {
145145
buildProperties.SetPath("sketch_path", sk.FullPath)
146+
buildProperties.Set("build.project_name", sk.MainFile.Base())
147+
buildProperties.SetPath("build.source.path", sk.FullPath)
146148
}
147149
if buildPath != nil {
148150
buildProperties.SetPath("build.path", buildPath)
149151
}
150-
if sk != nil {
151-
buildProperties.Set("build.project_name", sk.MainFile.Base())
152-
buildProperties.SetPath("build.source.path", sk.FullPath)
153-
}
154152
if optimizeForDebug {
155153
if debugFlags, ok := buildProperties.GetOk("compiler.optimization_flags.debug"); ok {
156154
buildProperties.Set("compiler.optimization_flags", debugFlags)
@@ -186,16 +184,20 @@ func NewBuilder(
186184
}
187185

188186
logger := logger.New(stdout, stderr, verbose, warningsLevel)
189-
libsResolver, verboseOut, err := detector.LibrariesLoader(
190-
useCachedLibrariesResolution, librariesManager,
191-
builtInLibrariesDirs, customLibraryDirs, librariesDirs,
192-
buildPlatform, targetPlatform,
187+
libsResolver, libsLoadingWarnings, err := detector.LibrariesLoader(
188+
useCachedLibrariesResolution,
189+
librariesManager,
190+
builtInLibrariesDirs,
191+
customLibraryDirs,
192+
librariesDirs,
193+
buildPlatform,
194+
targetPlatform,
193195
)
194196
if err != nil {
195197
return nil, err
196198
}
197199
if logger.Verbose() {
198-
logger.Warn(string(verboseOut))
200+
logger.Warn(string(libsLoadingWarnings))
199201
}
200202

201203
diagnosticStore := diagnostics.NewStore()
@@ -222,8 +224,10 @@ func NewBuilder(
222224
buildPlatform: buildPlatform,
223225
toolEnv: toolEnv,
224226
buildOptions: newBuildOptions(
225-
hardwareDirs, librariesDirs,
226-
builtInLibrariesDirs, buildPath,
227+
hardwareDirs,
228+
librariesDirs,
229+
builtInLibrariesDirs,
230+
buildPath,
227231
sk,
228232
customBuildProperties,
229233
fqbn,

internal/arduino/builder/internal/detector/detector.go

+14-18
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,11 @@ func findIncludeForOldCompilers(source string) string {
490490
func LibrariesLoader(
491491
useCachedLibrariesResolution bool,
492492
librariesManager *librariesmanager.LibrariesManager,
493-
builtInLibrariesDirs *paths.Path, libraryDirs, otherLibrariesDirs paths.PathList,
494-
actualPlatform, targetPlatform *cores.PlatformRelease,
493+
builtInLibrariesDir *paths.Path,
494+
customLibraryDirs paths.PathList,
495+
librariesDirs paths.PathList,
496+
buildPlatform *cores.PlatformRelease,
497+
targetPlatform *cores.PlatformRelease,
495498
) (*librariesresolver.Cpp, []byte, error) {
496499
verboseOut := &bytes.Buffer{}
497500
lm := librariesManager
@@ -503,21 +506,20 @@ func LibrariesLoader(
503506
if librariesManager == nil {
504507
lmb := librariesmanager.NewBuilder()
505508

506-
builtInLibrariesFolders := builtInLibrariesDirs
507-
if builtInLibrariesFolders != nil {
508-
if err := builtInLibrariesFolders.ToAbs(); err != nil {
509+
if builtInLibrariesDir != nil {
510+
if err := builtInLibrariesDir.ToAbs(); err != nil {
509511
return nil, nil, err
510512
}
511513
lmb.AddLibrariesDir(librariesmanager.LibrariesDir{
512-
Path: builtInLibrariesFolders,
514+
Path: builtInLibrariesDir,
513515
Location: libraries.IDEBuiltIn,
514516
})
515517
}
516518

517-
if actualPlatform != targetPlatform {
519+
if buildPlatform != targetPlatform {
518520
lmb.AddLibrariesDir(librariesmanager.LibrariesDir{
519-
PlatformRelease: actualPlatform,
520-
Path: actualPlatform.GetLibrariesDir(),
521+
PlatformRelease: buildPlatform,
522+
Path: buildPlatform.GetLibrariesDir(),
521523
Location: libraries.ReferencedPlatformBuiltIn,
522524
})
523525
}
@@ -527,7 +529,7 @@ func LibrariesLoader(
527529
Location: libraries.PlatformBuiltIn,
528530
})
529531

530-
librariesFolders := otherLibrariesDirs
532+
librariesFolders := librariesDirs
531533
if err := librariesFolders.ToAbs(); err != nil {
532534
return nil, nil, err
533535
}
@@ -538,7 +540,7 @@ func LibrariesLoader(
538540
})
539541
}
540542

541-
for _, dir := range libraryDirs {
543+
for _, dir := range customLibraryDirs {
542544
lmb.AddLibrariesDir(librariesmanager.LibrariesDir{
543545
Path: dir,
544546
Location: libraries.Unmanaged,
@@ -548,18 +550,12 @@ func LibrariesLoader(
548550

549551
newLm, libsLoadingWarnings := lmb.Build()
550552
for _, status := range libsLoadingWarnings {
551-
// With the refactoring of the initialization step of the CLI we changed how
552-
// errors are returned when loading platforms and libraries, that meant returning a list of
553-
// errors instead of a single one to enhance the experience for the user.
554-
// I have no intention right now to start a refactoring of the legacy package too, so
555-
// here's this shitty solution for now.
556-
// When we're gonna refactor the legacy package this will be gone.
557553
verboseOut.Write([]byte(status.Message()))
558554
}
559555
lm = newLm
560556
}
561557

562558
allLibs := lm.FindAllInstalled()
563-
resolver := librariesresolver.NewCppResolver(allLibs, targetPlatform, actualPlatform)
559+
resolver := librariesresolver.NewCppResolver(allLibs, targetPlatform, buildPlatform)
564560
return resolver, verboseOut.Bytes(), nil
565561
}

0 commit comments

Comments
 (0)