Skip to content

Commit 6bf928a

Browse files
committed
Renamed variables for clarity
1 parent 054e725 commit 6bf928a

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
logger := logger.New(stdout, stderr, verbose, warningsLevel)
190-
libsResolver, verboseOut, err := detector.LibrariesLoader(
191-
useCachedLibrariesResolution, librariesManager,
192-
builtInLibrariesDirs, customLibraryDirs, librariesDirs,
193-
buildPlatform, targetPlatform,
188+
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 logger.Verbose() {
199-
logger.Warn(string(verboseOut))
201+
logger.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
@@ -489,8 +489,11 @@ func findIncludeForOldCompilers(source string) string {
489489
func LibrariesLoader(
490490
useCachedLibrariesResolution bool,
491491
librariesManager *librariesmanager.LibrariesManager,
492-
builtInLibrariesDirs *paths.Path, libraryDirs, otherLibrariesDirs paths.PathList,
493-
actualPlatform, targetPlatform *cores.PlatformRelease,
492+
builtInLibrariesDir *paths.Path,
493+
customLibraryDirs paths.PathList,
494+
librariesDirs paths.PathList,
495+
buildPlatform *cores.PlatformRelease,
496+
targetPlatform *cores.PlatformRelease,
494497
) (*librariesresolver.Cpp, []byte, error) {
495498
verboseOut := &bytes.Buffer{}
496499
lm := librariesManager
@@ -502,21 +505,20 @@ func LibrariesLoader(
502505
if librariesManager == nil {
503506
lmb := librariesmanager.NewBuilder()
504507

505-
builtInLibrariesFolders := builtInLibrariesDirs
506-
if builtInLibrariesFolders != nil {
507-
if err := builtInLibrariesFolders.ToAbs(); err != nil {
508+
if builtInLibrariesDir != nil {
509+
if err := builtInLibrariesDir.ToAbs(); err != nil {
508510
return nil, nil, err
509511
}
510512
lmb.AddLibrariesDir(librariesmanager.LibrariesDir{
511-
Path: builtInLibrariesFolders,
513+
Path: builtInLibrariesDir,
512514
Location: libraries.IDEBuiltIn,
513515
})
514516
}
515517

516-
if actualPlatform != targetPlatform {
518+
if buildPlatform != targetPlatform {
517519
lmb.AddLibrariesDir(librariesmanager.LibrariesDir{
518-
PlatformRelease: actualPlatform,
519-
Path: actualPlatform.GetLibrariesDir(),
520+
PlatformRelease: buildPlatform,
521+
Path: buildPlatform.GetLibrariesDir(),
520522
Location: libraries.ReferencedPlatformBuiltIn,
521523
})
522524
}
@@ -526,7 +528,7 @@ func LibrariesLoader(
526528
Location: libraries.PlatformBuiltIn,
527529
})
528530

529-
librariesFolders := otherLibrariesDirs
531+
librariesFolders := librariesDirs
530532
if err := librariesFolders.ToAbs(); err != nil {
531533
return nil, nil, err
532534
}
@@ -537,7 +539,7 @@ func LibrariesLoader(
537539
})
538540
}
539541

540-
for _, dir := range libraryDirs {
542+
for _, dir := range customLibraryDirs {
541543
lmb.AddLibrariesDir(librariesmanager.LibrariesDir{
542544
Path: dir,
543545
Location: libraries.Unmanaged,
@@ -547,18 +549,12 @@ func LibrariesLoader(
547549

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

561557
allLibs := lm.FindAllInstalled()
562-
resolver := librariesresolver.NewCppResolver(allLibs, targetPlatform, actualPlatform)
558+
resolver := librariesresolver.NewCppResolver(allLibs, targetPlatform, buildPlatform)
563559
return resolver, verboseOut.Bytes(), nil
564560
}

0 commit comments

Comments
 (0)