8000 Some refactorings on library resolution code by cmaglie · Pull Request #1766 · arduino/arduino-cli · GitHub
[go: up one dir, main page]

Skip to content

Some refactorings on library resolution code #1766

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

Merged
merged 8 commits into from
Aug 25, 2023
Merged
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
Keep extra-include dirs due to "utility" folder in SourceFile object
Also remove the reference to the original Library object because it's no
more needed.
  • Loading branch information
cmaglie committed Jun 12, 2023
commit 22fd8e23dd491617aba64fa77c7bd92c63c2ada3
5 changes: 2 additions & 3 deletions legacy/builder/container_find_includes.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,8 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFileQu
// copy the current search path list and add the library' utility directory
// if needed.
includeFolders := ctx.IncludeFolders
if library := sourceFile.Library; library != nil && library.UtilityDir != nil {
includeFolders = append(includeFolders, library.UtilityDir)
}
if extraInclude := sourceFile.ExtraIncludePath(); extraInclude != nil {
includeFolders = append(includeFolders, extraInclude)
}

var preprocErr error
Expand Down
14 c 8000 hanges: 10 additions & 4 deletions legacy/builder/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ type SourceFile struct {
// Path to the source file within the sketch/library root folder
relativePath *paths.Path

// Set to the Library object of origin if this source file comes
// from a library
Library *libraries.Library
// ExtraIncludePath contains an extra include path that must be
// used to compile this source file.
// This is mainly used for source files that comes from old-style libraries
// (Arduino IDE <1.5) requiring an extra include path to the "utility" folder.
extraIncludePath *paths.Path

// The source root for the given origin, where its source files
// can be found. Prepending this to SourceFile.RelativePath will give
Expand Down Expand Up @@ -61,7 +63,7 @@ func MakeSourceFile(ctx *Context, origin interface{}, path *paths.Path) (*Source
case *libraries.Library:
res.buildRoot = ctx.LibrariesBuildPath.Join(o.DirName)
res.sourceRoot = o.SourceDir
res.Library = o
res.extraIncludePath = o.UtilityDir
default:
panic("Unexpected origin for SourceFile: " + fmt.Sprint(origin))
}
Expand All @@ -77,6 +79,10 @@ func MakeSourceFile(ctx *Context, origin interface{}, path *paths.Path) (*Source
return res, nil
}

func (f *SourceFile) ExtraIncludePath() *paths.Path {
return f.extraIncludePath
}

func (f *SourceFile) SourcePath() *paths.Path {
return f.sourceRoot.JoinPath(f.relativePath)
}
Expand Down
0