Skip to content

Commit

Permalink
remove LibrariesResolutionResults from context
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Sep 1, 2023
1 parent cff9cdc commit 39879df
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 68 deletions.
32 changes: 32 additions & 0 deletions arduino/builder/libraries.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package builder
import (
"bytes"
"fmt"
"strings"
"time"

"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/arduino/libraries"
Expand Down Expand Up @@ -125,6 +127,36 @@ func (l *SketchLibrariesDetector) UseCachedLibrariesResolution() bool {
return l.useCachedLibrariesResolution
}

func (l *SketchLibrariesDetector) PrintUsedAndNotUsedLibraries(sketchError bool) {

Check failure on line 130 in arduino/builder/libraries.go

View workflow job for this annotation

GitHub Actions / check-style (./)

exported method SketchLibrariesDetector.PrintUsedAndNotUsedLibraries should have comment or be unexported
// Print this message:
// - as warning, when the sketch didn't compile
// - as info, when verbose is on
// - otherwise, output nothing
if !sketchError && !l.verbose {
return
}

res := ""
for header, libResResult := range l.librariesResolutionResults {
if len(libResResult.NotUsedLibraries) == 0 {
continue
}
res += fmt.Sprintln(tr(`Multiple libraries were found for "%[1]s"`, header))
res += fmt.Sprintln(" " + tr("Used: %[1]s", libResResult.Library.InstallDir))
for _, notUsedLibrary := range libResResult.NotUsedLibraries {
res += fmt.Sprintln(" " + tr("Not used: %[1]s", notUsedLibrary.InstallDir))
}
}
res = strings.TrimSpace(res)
if sketchError {
l.verboseWarnFn(res)
} else {
l.verboseInfoFn(res)
}
// todo why?? should we remove this?
time.Sleep(100 * time.Millisecond)
}

// AppendIncludeFolder todo should rename this, probably after refactoring the
// container_find_includes command.
//func (l *SketchLibrariesDetector) AppendIncludeFolder(ctx *types.Context, cache *includeCache, sourceFilePath *paths.Path, include string, folder *paths.Path) {
Expand Down
5 changes: 4 additions & 1 deletion legacy/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ func (s *Builder) Run(ctx *types.Context) error {

var otherErr error
commands = []types.Command{
&PrintUsedAndNotUsedLibraries{SketchError: mainErr != nil},
types.BareCommand(func(ctx *types.Context) error {
ctx.SketchLibrariesDetector.PrintUsedAndNotUsedLibraries(mainErr != nil)
return nil
}),

&PrintUsedLibrariesIfVerbose{},

Expand Down
59 changes: 0 additions & 59 deletions legacy/builder/print_used_and_not_used_libraries.go

This file was deleted.

5 changes: 2 additions & 3 deletions legacy/builder/types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ type Context struct {
WarningsLevel string

// Libraries handling
LibrariesManager *librariesmanager.LibrariesManager
LibrariesResolutionResults map[string]LibraryResolutionResult
IncludeFolders paths.PathList
LibrariesManager *librariesmanager.LibrariesManager
IncludeFolders paths.PathList

// C++ Parsing
LineOffset int
Expand Down
5 changes: 0 additions & 5 deletions legacy/builder/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ func (f *SourceFile) DepfilePath() *paths.Path {
return f.buildRoot.Join(f.relativePath.String() + ".d")
}

type LibraryResolutionResult struct {
Library *libraries.Library
NotUsedLibraries []*libraries.Library
}

type Command interface {
Run(ctx *Context) error
}
Expand Down

0 comments on commit 39879df

Please sign in to comment.