8000 Add possibility to embed custom libraries into the sketch by cmaglie · Pull Request #2514 · arduino/arduino-cli · GitHub
[go: up one dir, main page]

Skip to content

Add possibility to embed custom libraries into the sketch #2514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow compile of sketch-vendored libraries
  • Loading branch information
cmaglie committed Nov 12, 2024
commit 89afc677e857804d9d83ec5cfbd0eef2cd0205af
2 changes: 1 addition & 1 deletion internal/arduino/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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 @@ -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) {
Expand Down Expand Up @@ -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
}

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 @@ -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"
Expand All @@ -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{},
}
Expand All @@ -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) {
Expand Down
0