diff --git a/internal/arduino/builder/builder.go b/internal/arduino/builder/builder.go index 91c74965782..3e71c22e46a 100644 --- a/internal/arduino/builder/builder.go +++ b/internal/arduino/builder/builder.go @@ -191,7 +191,7 @@ func NewBuilder( logger := logger.New(stdout, stderr, verbose, warningsLevel) libsManager, libsResolver, verboseOut, err := detector.LibrariesLoader( useCachedLibrariesResolution, librariesManager, - builtInLibrariesDirs, libraryDirs, otherLibrariesDirs, + sk, builtInLibrariesDirs, libraryDirs, otherLibrariesDirs, actualPlatform, targetPlatform, ) if err != nil { diff --git a/internal/arduino/builder/internal/detector/detector.go b/internal/arduino/builder/internal/detector/detector.go index 17de9377833..84463d41e27 100644 --- a/internal/arduino/builder/internal/detector/detector.go +++ b/internal/arduino/builder/internal/detector/detector.go @@ -597,6 +597,7 @@ func (f *sourceFile) DepfilePath() *paths.Path { func LibrariesLoader( useCachedLibrariesResolution bool, librariesManager *librariesmanager.LibrariesManager, + sk *sketch.Sketch, builtInLibrariesDirs *paths.Path, libraryDirs, otherLibrariesDirs paths.PathList, actualPlatform, targetPlatform *cores.PlatformRelease, ) (*librariesmanager.LibrariesManager, *librariesresolver.Cpp, []byte, error) { @@ -667,7 +668,7 @@ func LibrariesLoader( } allLibs := lm.FindAllInstalled() - resolver := librariesresolver.NewCppResolver(allLibs, targetPlatform, actualPlatform) + resolver := librariesresolver.NewCppResolver(allLibs, sk, targetPlatform, actualPlatform) return lm, resolver, verboseOut.Bytes(), nil } diff --git a/internal/arduino/libraries/librariesresolver/cpp.go b/internal/arduino/libraries/librariesresolver/cpp.go index e842b764ace..e2ae916d396 100644 --- a/internal/arduino/libraries/librariesresolver/cpp.go +++ b/internal/arduino/libraries/librariesresolver/cpp.go @@ -23,6 +23,7 @@ import ( "github.com/arduino/arduino-cli/internal/arduino/cores" "github.com/arduino/arduino-cli/internal/arduino/libraries" + "github.com/arduino/arduino-cli/internal/arduino/sketch" "github.com/arduino/arduino-cli/internal/arduino/utils" "github.com/arduino/arduino-cli/internal/i18n" "github.com/schollz/closestmatch" @@ -35,7 +36,7 @@ type Cpp struct { } // NewCppResolver creates a new Cpp resolver -func NewCppResolver(allLibs []*libraries.Library, targetPlatform, actualPlatform *cores.PlatformRelease) *Cpp { +func NewCppResolver(allLibs []*libraries.Library, sk *sketch.Sketch, targetPlatform, actualPlatform *cores.PlatformRelease) *Cpp { resolver := &Cpp{ headers: map[string]libraries.List{}, } @@ -45,10 +46,17 @@ func NewCppResolver(allLibs []*libraries.Library, targetPlatform, actualPlatform if actualPlatform != targetPlatform { resolver.ScanPlatformLibraries(allLibs, actualPlatform) } - + resolver.ScanSketchLibraries(sk) return resolver } +// ScanSketchLibraries loads libraries bundled with the sketch +func (resolver *Cpp) ScanSketchLibraries(sk *sketch.Sketch) { + for _, lib := range sk.VendoredLibraries() { + _ = resolver.ScanLibrary(lib) + } +} + // ScanIDEBuiltinLibraries reads ide-builtin librariers loaded in the LibrariesManager to find // and cache all C++ headers for later retrieval. func (resolver *Cpp) ScanIDEBuiltinLibraries(allLibs []*libraries.Library) {