Skip to content

Commit 8da2287

Browse files
make PrintUsedLibraries a method recevier of arduino/builder
1 parent c0eed43 commit 8da2287

File tree

3 files changed

+35
-56
lines changed

3 files changed

+35
-56
lines changed

arduino/builder/libraries.go

+34
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package builder
1717

1818
import (
1919
"strings"
20+
"time"
2021

2122
"github.com/arduino/arduino-cli/arduino/builder/compilation"
2223
"github.com/arduino/arduino-cli/arduino/builder/cpp"
@@ -343,3 +344,36 @@ func (b *Builder) WarnAboutArchIncompatibleLibraries(
343344
}
344345
}
345346
}
347+
348+
// PrintUsedLibraries fixdoc
349+
// TODO here we can completly remove this part as it's duplicated in what we can
350+
// read in the gRPC response
351+
func (b *Builder) PrintUsedLibraries(importedLibraries libraries.List) {
352+
if !b.logger.Verbose() || len(importedLibraries) == 0 {
353+
return
354+
}
355+
356+
for _, library := range importedLibraries {
357+
legacy := ""
358+
if library.IsLegacy {
359+
legacy = tr("(legacy)")
360+
}
361+
if library.Version.String() == "" {
362+
b.logger.Info(
363+
tr("Using library %[1]s in folder: %[2]s %[3]s",
364+
library.Name,
365+
library.InstallDir,
366+
legacy))
367+
} else {
368+
b.logger.Info(
369+
tr("Using library %[1]s at version %[2]s in folder: %[3]s %[4]s",
370+
library.Name,
371+
library.Version,
372+
library.InstallDir,
373+
legacy))
374+
}
375+
}
376+
377+
// TODO Why is this here?
378+
time.Sleep(100 * time.Millisecond)
379+
}

legacy/builder/builder.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@ func (s *Builder) Run(ctx *types.Context) error {
211211
}),
212212

213213
types.BareCommand(func(ctx *types.Context) error {
214-
infoOut, _ := PrintUsedLibrariesIfVerbose(ctx.BuilderLogger.Verbose(), ctx.SketchLibrariesDetector.ImportedLibraries())
215-
ctx.BuilderLogger.Info(string(infoOut))
214+
ctx.Builder.PrintUsedLibraries(ctx.SketchLibrariesDetector.ImportedLibraries())
216215
return nil
217216
}),
218217

legacy/builder/print_used_libraries_if_verbose.go

-54
This file was deleted.

0 commit comments

Comments
 (0)