Skip to content

Commit

Permalink
Allow compile of sketch-vendored libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Jan 24, 2024
1 parent 6e9e305 commit 10dd714
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/arduino/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,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 {
Expand Down
3 changes: 2 additions & 1 deletion internal/arduino/builder/internal/detector/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,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) {
Expand Down Expand Up @@ -660,7 +661,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
}

Expand Down
12 changes: 10 additions & 2 deletions internal/arduino/libraries/librariesresolver/cpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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"
Expand All @@ -36,7 +37,7 @@ type Cpp struct {
var tr = i18n.Tr

// 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{},
}
Expand All @@ -46,10 +47,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) {
Expand Down

0 comments on commit 10dd714

Please sign in to comment.