Skip to content

Commit 22fd8e2

Browse files
committed
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.
1 parent 48bc522 commit 22fd8e2

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Diff for: legacy/builder/container_find_includes.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,8 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFileQu
340340
// copy the current search path list and add the library' utility directory
341341
// if needed.
342342
includeFolders := ctx.IncludeFolders
343-
if library := sourceFile.Library; library != nil && library.UtilityDir != nil {
344-
includeFolders = append(includeFolders, library.UtilityDir)
345-
}
343+
if extraInclude := sourceFile.ExtraIncludePath(); extraInclude != nil {
344+
includeFolders = append(includeFolders, extraInclude)
346345
}
347346

348347
var preprocErr error

Diff for: legacy/builder/types/types.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ type SourceFile struct {
2727
// Path to the source file within the sketch/library root folder
2828
relativePath *paths.Path
2929

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

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

82+
func (f *SourceFile) ExtraIncludePath() *paths.Path {
83+
return f.extraIncludePath
84+
}
85+
8086
func (f *SourceFile) SourcePath() *paths.Path {
8187
return f.sourceRoot.JoinPath(f.relativePath)
8288
}

0 commit comments

Comments
 (0)