Skip to content

Commit

Permalink
remove LibrariesManager from context
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Sep 1, 2023
1 parent 56b7611 commit 34f52c3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
14 changes: 7 additions & 7 deletions commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/arduino/arduino-cli/arduino"
bldr "github.com/arduino/arduino-cli/arduino/builder"
"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/arduino/libraries/librariesmanager"
"github.com/arduino/arduino-cli/arduino/sketch"
"github.com/arduino/arduino-cli/arduino/utils"
"github.com/arduino/arduino-cli/buildcache"
Expand Down Expand Up @@ -248,27 +249,26 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
}
}

// TODO replace all UseCache call with our SketchLibrariesDetector
useCachedLibrariesResolution := req.GetSkipLibrariesDiscovery()
var libsManager *librariesmanager.LibrariesManager
if pme.GetProfile() != nil {
builderCtx.LibrariesManager = lm
libsManager = lm
}
lm, libsResolver, verboseOut, err := bldr.LibrariesLoader(
useCachedLibrariesResolution, builderCtx.LibrariesManager,
useCachedLibrariesResolution := req.GetSkipLibrariesDiscovery()
libsManager, libsResolver, verboseOut, err := bldr.LibrariesLoader(
useCachedLibrariesResolution, libsManager,
builderCtx.BuiltInLibrariesDirs, builderCtx.LibraryDirs, builderCtx.OtherLibrariesDirs,
builderCtx.ActualPlatform, builderCtx.TargetPlatform,
)
if err != nil {
return r, &arduino.CompileFailedError{Message: err.Error()}
}

builderCtx.LibrariesManager = lm
if builderCtx.Verbose {
builderCtx.Warn(string(verboseOut))
}

builderCtx.SketchLibrariesDetector = bldr.NewSketchLibrariesDetector(
lm, libsResolver,
libsManager, libsResolver,
builderCtx.Verbose,
useCachedLibrariesResolution,
func(msg string) { builderCtx.Info(msg) },
Expand Down
3 changes: 1 addition & 2 deletions legacy/builder/test/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,12 @@ func prepareBuilderTestContext(t *testing.T, ctx *types.Context, sketchPath *pat

if !stepToSkip[skipLibraries] {
lm, libsResolver, _, err := bldr.LibrariesLoader(
false, ctx.LibrariesManager,
false, nil,
ctx.BuiltInLibrariesDirs, ctx.LibraryDirs, ctx.OtherLibrariesDirs,
ctx.ActualPlatform, ctx.TargetPlatform,
)
NoError(t, err)

ctx.LibrariesManager = lm
ctx.SketchLibrariesDetector = bldr.NewSketchLibrariesDetector(
lm, libsResolver,
ctx.Verbose,
Expand Down
8 changes: 4 additions & 4 deletions legacy/builder/test/libraries_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestLoadLibrariesAVR(t *testing.T) {
defer cleanUpBuilderTestContext(t, ctx)

lm, libsResolver, _, err := builder.LibrariesLoader(
false, ctx.LibrariesManager,
false, nil,
ctx.BuiltInLibrariesDirs, ctx.LibraryDirs, ctx.OtherLibrariesDirs,
ctx.ActualPlatform, ctx.TargetPlatform,
)
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestLoadLibrariesSAM(t *testing.T) {
defer cleanUpBuilderTestContext(t, ctx)

lm, libsResolver, _, err := builder.LibrariesLoader(
false, ctx.LibrariesManager,
false, nil,
ctx.BuiltInLibrariesDirs, ctx.LibraryDirs, ctx.OtherLibrariesDirs,
ctx.ActualPlatform, ctx.TargetPlatform,
)
Expand Down Expand Up @@ -229,7 +229,7 @@ func TestLoadLibrariesAVRNoDuplicateLibrariesFolders(t *testing.T) {
defer cleanUpBuilderTestContext(t, ctx)

lm, _, _, err := builder.LibrariesLoader(
false, ctx.LibrariesManager,
false, nil,
ctx.BuiltInLibrariesDirs, ctx.LibraryDirs, ctx.OtherLibrariesDirs,
ctx.ActualPlatform, ctx.TargetPlatform,
)
Expand All @@ -252,7 +252,7 @@ func TestLoadLibrariesMyAVRPlatform(t *testing.T) {
defer cleanUpBuilderTestContext(t, ctx)

lm, _, _, err := builder.LibrariesLoader(
false, ctx.LibrariesManager,
false, nil,
ctx.BuiltInLibrariesDirs, ctx.LibraryDirs, ctx.OtherLibrariesDirs,
ctx.ActualPlatform, ctx.TargetPlatform,
)
Expand Down
2 changes: 0 additions & 2 deletions legacy/builder/types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/arduino/arduino-cli/arduino/builder"
"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/arduino/libraries/librariesmanager"
"github.com/arduino/arduino-cli/arduino/sketch"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
paths "github.com/arduino/go-paths-helper"
Expand Down Expand Up @@ -102,7 +101,6 @@ type Context struct {
WarningsLevel string

// Libraries handling
LibrariesManager *librariesmanager.LibrariesManager
IncludeFolders paths.PathList

// C++ Parsing
Expand Down

0 comments on commit 34f52c3

Please sign in to comment.