Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 704f37c

Browse files
committedSep 28, 2020
Do not overwrite full headers list with declared 'includes' in library.properties
Otherwise the automatic library discovery would be affected. Fix #960
1 parent 69ac12c commit 704f37c

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed
 

‎arduino/libraries/libraries.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ type Library struct {
7373
License string
7474
Properties *properties.Map
7575
Examples paths.PathList
76+
declaredHeaders []string
7677
sourceHeaders []string
7778
}
7879

@@ -157,7 +158,15 @@ func (library *Library) LocationPriorityFor(platformRelease, refPlatformRelease
157158
return 0
158159
}
159160

160-
// SourceHeaders returns the C++ headers in the library.
161+
// DeclaredHeaders returns the C++ headers that the library declares in library.properties
162+
func (library *Library) DeclaredHeaders() []string {
163+
if library.declaredHeaders == nil {
164+
library.declaredHeaders = []string{}
165+
}
166+
return library.declaredHeaders
167+
}
168+
169+
// SourceHeaders returns all the C++ headers in the library even if not declared in library.properties
161170
func (library *Library) SourceHeaders() ([]string, error) {
162171
if library.sourceHeaders == nil {
163172
cppHeaders, err := library.SourceDir.ReadDir()

‎arduino/libraries/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func makeNewLibrary(libraryDir *paths.Path, location LibraryLocation) (*Library,
101101
}
102102

103103
if includes := libProperties.Get("includes"); includes != "" {
104-
library.sourceHeaders = commaSeparatedToList(includes)
104+
library.declaredHeaders = commaSeparatedToList(includes)
105105
}
106106

107107
if err := addExamples(library); err != nil {

‎commands/lib/list.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,6 @@ func GetOutputLibrary(lib *libraries.Library) (*rpc.Library, error) {
146146
cntplat = lib.ContainerPlatform.String()
147147
}
148148

149-
libHeaders, err := lib.SourceHeaders()
150-
if err != nil {
151-
return nil, errors.Errorf("getting library headers: %s", err)
152-
}
153-
154149
return &rpc.Library{
155150
Name: lib.Name,
156151
Author: lib.Author,
@@ -175,7 +170,7 @@ func GetOutputLibrary(lib *libraries.Library) (*rpc.Library, error) {
175170
Version: lib.Version.String(),
176171
License: lib.License,
177172
Examples: lib.Examples.AsStrings(),
178-
ProvidesIncludes: libHeaders,
173+
ProvidesIncludes: lib.DeclaredHeaders(),
179174
}, nil
180175
}
181176

0 commit comments

Comments
 (0)
Please sign in to comment.