Skip to content

Commit 7eb04d0

Browse files
committed
Renamed variables for clarity
1 parent 688f28f commit 7eb04d0

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

internal/arduino/builder/builder.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,12 @@ func NewBuilder(
144144
}
145145
if sk != nil {
146146
buildProperties.SetPath("sketch_path", sk.FullPath)
147+
buildProperties.Set("build.project_name", sk.MainFile.Base())
148+
buildProperties.SetPath("build.source.path", sk.FullPath)
147149
}
148150
if buildPath != nil {
149151
buildProperties.SetPath("build.path", buildPath)
150152
}
151-
if sk != nil {
152-
buildProperties.Set("build.project_name", sk.MainFile.Base())
153-
buildProperties.SetPath("build.source.path", sk.FullPath)
154-
}
155153
if optimizeForDebug {
156154
if debugFlags, ok := buildProperties.GetOk("compiler.optimization_flags.debug"); ok {
157155
buildProperties.Set("compiler.optimization_flags", debugFlags)
@@ -187,16 +185,20 @@ func NewBuilder(
187185
}
188186

189187
log := logger.New(stdout, stderr, verbosity, warningsLevel)
190-
libsManager, libsResolver, verboseOut, err := detector.LibrariesLoader(
191-
useCachedLibrariesResolution, librariesManager,
192-
builtInLibrariesDirs, customLibraryDirs, librariesDirs,
193-
buildPlatform, targetPlatform,
188+
libsManager, libsResolver, libsLoadingWarnings, err := detector.LibrariesLoader(
189+
useCachedLibrariesResolution,
190+
librariesManager,
191+
builtInLibrariesDirs,
192+
customLibraryDirs,
193+
librariesDirs,
194+
buildPlatform,
195+
targetPlatform,
194196
)
195197
if err != nil {
196198
return nil, err
197199
}
198200
if log.VerbosityLevel() == logger.VerbosityVerbose {
199-
log.Warn(string(verboseOut))
201+
log.Warn(string(libsLoadingWarnings))
200202
}
201203

202204
diagnosticStore := diagnostics.NewStore()
@@ -223,8 +225,10 @@ func NewBuilder(
223225
buildPlatform: buildPlatform,
224226
toolEnv: toolEnv,
225227
buildOptions: newBuildOptions(
226-
hardwareDirs, librariesDirs,
227-
builtInLibrariesDirs, buildPath,
228+
hardwareDirs,
229+
librariesDirs,
230+
builtInLibrariesDirs,
231+
buildPath,
228232
sk,
229233
customBuildProperties,
230234
fqbn,

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

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,11 @@ func findIncludeForOldCompilers(source string) string {
505505
func LibrariesLoader(
506506
useCachedLibrariesResolution bool,
507507
librariesManager *librariesmanager.LibrariesManager,
508-
builtInLibrariesDirs *paths.Path, libraryDirs, otherLibrariesDirs paths.PathList,
509-
actualPlatform, targetPlatform *cores.PlatformRelease,
508+
builtInLibrariesDir *paths.Path,
509+
customLibraryDirs paths.PathList, // libraryDirs paths.PathList,
510+
librariesDirs paths.PathList, // otherLibrariesDirs paths.PathList,
511+
buildPlatform *cores.PlatformRelease,
512+
targetPlatform *cores.PlatformRelease,
510513
) (*librariesmanager.LibrariesManager, *librariesresolver.Cpp, []byte, error) {
511514
verboseOut := &bytes.Buffer{}
512515
lm := librariesManager
@@ -518,21 +521,20 @@ func LibrariesLoader(
518521
if librariesManager == nil {
519522
lmb := librariesmanager.NewBuilder()
520523

521-
builtInLibrariesFolders := builtInLibrariesDirs
522-
if builtInLibrariesFolders != nil {
523-
if err := builtInLibrariesFolders.ToAbs(); err != nil {
524+
if builtInLibrariesDir != nil {
525+
if err := builtInLibrariesDir.ToAbs(); err != nil {
524526
return nil, nil, nil, err
525527
}
526528
lmb.AddLibrariesDir(librariesmanager.LibrariesDir{
527-
Path: builtInLibrariesFolders,
529+
Path: builtInLibrariesDir,
528530
Location: libraries.IDEBuiltIn,
529531
})
530532
}
531533

532-
if actualPlatform != targetPlatform {
534+
if buildPlatform != targetPlatform {
533535
lmb.AddLibrariesDir(librariesmanager.LibrariesDir{
534-
PlatformRelease: actualPlatform,
535-
Path: actualPlatform.GetLibrariesDir(),
536+
PlatformRelease: buildPlatform,
537+
Path: buildPlatform.GetLibrariesDir(),
536538
Location: libraries.ReferencedPlatformBuiltIn,
537539
})
538540
}
@@ -542,7 +544,7 @@ func LibrariesLoader(
542544
Location: libraries.PlatformBuiltIn,
543545
})
544546

545-
librariesFolders := otherLibrariesDirs
547+
librariesFolders := librariesDirs
546548
if err := librariesFolders.ToAbs(); err != nil {
547549
return nil, nil, nil, err
548550
}
@@ -553,7 +555,7 @@ func LibrariesLoader(
553555
})
554556
}
555557

556-
for _, dir := range libraryDirs {
558+
for _, dir := range customLibraryDirs {
557559
lmb.AddLibrariesDir(librariesmanager.LibrariesDir{
558560
Path: dir,
559561
Location: libraries.Unmanaged,
@@ -563,18 +565,12 @@ func LibrariesLoader(
563565

564566
newLm, libsLoadingWarnings := lmb.Build()
565567
for _, status := range libsLoadingWarnings {
566-
// With the refactoring of the initialization step of the CLI we changed how
567-
// errors are returned when loading platforms and libraries, that meant returning a list of
568-
// errors instead of a single one to enhance the experience for the user.
569-
// I have no intention right now to start a refactoring of the legacy package too, so
570-
// here's this shitty solution for now.
571-
// When we're gonna refactor the legacy package this will be gone.
572568
verboseOut.Write([]byte(status.Message()))
573569
}
574570
lm = newLm
575571
}
576572

577573
allLibs := lm.FindAllInstalled()
578-
resolver := librariesresolver.NewCppResolver(allLibs, targetPlatform, actualPlatform)
574+
resolver := librariesresolver.NewCppResolver(allLibs, targetPlatform, buildPlatform)
579575
return lm, resolver, verboseOut.Bytes(), nil
580576
}

0 commit comments

Comments
 (0)