Skip to content

Commit 89afc67

Browse files
committed
Allow compile of sketch-vendored libraries
1 parent d02fc83 commit 89afc67

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

internal/arduino/builder/builder.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func NewBuilder(
191191
logger := logger.New(stdout, stderr, verbose, warningsLevel)
192192
libsManager, libsResolver, verboseOut, err := detector.LibrariesLoader(
193193
useCachedLibrariesResolution, librariesManager,
194-
builtInLibrariesDirs, libraryDirs, otherLibrariesDirs,
194+
sk, builtInLibrariesDirs, libraryDirs, otherLibrariesDirs,
195195
actualPlatform, targetPlatform,
196196
)
197197
if err != nil {

internal/arduino/builder/internal/detector/detector.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ func (f *sourceFile) DepfilePath() *paths.Path {
597597
func LibrariesLoader(
598598
useCachedLibrariesResolution bool,
599599
librariesManager *librariesmanager.LibrariesManager,
600+
sk *sketch.Sketch,
600601
builtInLibrariesDirs *paths.Path, libraryDirs, otherLibrariesDirs paths.PathList,
601602
actualPlatform, targetPlatform *cores.PlatformRelease,
602603
) (*librariesmanager.LibrariesManager, *librariesresolver.Cpp, []byte, error) {
@@ -667,7 +668,7 @@ func LibrariesLoader(
667668
}
668669

669670
allLibs := lm.FindAllInstalled()
670-
resolver := librariesresolver.NewCppResolver(allLibs, targetPlatform, actualPlatform)
671+
resolver := librariesresolver.NewCppResolver(allLibs, sk, targetPlatform, actualPlatform)
671672
return lm, resolver, verboseOut.Bytes(), nil
672673
}
673674

internal/arduino/libraries/librariesresolver/cpp.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/arduino/arduino-cli/internal/arduino/cores"
2525
"github.com/arduino/arduino-cli/internal/arduino/libraries"
26+
"github.com/arduino/arduino-cli/internal/arduino/sketch"
2627
"github.com/arduino/arduino-cli/internal/arduino/utils"
2728
"github.com/arduino/arduino-cli/internal/i18n"
2829
"github.com/schollz/closestmatch"
@@ -35,7 +36,7 @@ type Cpp struct {
3536
}
3637

3738
// NewCppResolver creates a new Cpp resolver
38-
func NewCppResolver(allLibs []*libraries.Library, targetPlatform, actualPlatform *cores.PlatformRelease) *Cpp {
39+
func NewCppResolver(allLibs []*libraries.Library, sk *sketch.Sketch, targetPlatform, actualPlatform *cores.PlatformRelease) *Cpp {
3940
resolver := &Cpp{
4041
headers: map[string]libraries.List{},
4142
}
@@ -45,10 +46,17 @@ func NewCppResolver(allLibs []*libraries.Library, targetPlatform, actualPlatform
4546
if actualPlatform != targetPlatform {
4647
resolver.ScanPlatformLibraries(allLibs, actualPlatform)
4748
}
48-
49+
resolver.ScanSketchLibraries(sk)
4950
return resolver
5051
}
5152

53+
// ScanSketchLibraries loads libraries bundled with the sketch
54+
func (resolver *Cpp) ScanSketchLibraries(sk *sketch.Sketch) {
55+
for _, lib := range sk.VendoredLibraries() {
56+
_ = resolver.ScanLibrary(lib)
57+
}
58+
}
59+
5260
// ScanIDEBuiltinLibraries reads ide-builtin librariers loaded in the LibrariesManager to find
5361
// and cache all C++ headers for later retrieval.
5462
func (resolver *Cpp) ScanIDEBuiltinLibraries(allLibs []*libraries.Library) {

0 commit comments

Comments
 (0)