Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 63634c7

Browse files
committed
Added 'provides_includes' field in 'lib list' output structures
1 parent 80e2c2e commit 63634c7

File tree

6 files changed

+67
-27
lines changed

6 files changed

+67
-27
lines changed

‎arduino/libraries/libraries.go‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package libraries
1717

1818
import (
19+
"fmt"
20+
1921
"github.com/arduino/arduino-cli/arduino/cores"
2022
paths "github.com/arduino/go-paths-helper"
2123
properties "github.com/arduino/go-properties-orderedmap"
@@ -71,6 +73,7 @@ type Library struct {
7173
License string
7274
Properties *properties.Map
7375
Examples paths.PathList
76+
sourceHeaders []string
7477
}
7578

7679
func (library *Library) String() string {
@@ -153,3 +156,20 @@ func (library *Library) LocationPriorityFor(platformRelease, refPlatformRelease
153156
}
154157
return 0
155158
}
159+
160+
// SourceHeaders returns the C++ headers in the library.
161+
func (library *Library) SourceHeaders() ([]string, error) {
162+
if library.sourceHeaders == nil {
163+
cppHeaders, err := library.SourceDir.ReadDir()
164+
if err != nil {
165+
return nil, fmt.Errorf("reading lib src dir: %s", err)
166+
}
167+
cppHeaders.FilterSuffix(".h", ".hpp", ".hh")
168+
res := []string{}
169+
for _, cppHeader := range cppHeaders {
170+
res = append(res, cppHeader.Base())
171+
}
172+
library.sourceHeaders = res
173+
}
174+
return library.sourceHeaders, nil
175+
}

‎arduino/libraries/librariesresolver/cpp.go‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,11 @@ func (resolver *Cpp) ScanFromLibrariesManager(lm *librariesmanager.LibrariesMana
5252

5353
// ScanLibrary reads a library to find and cache C++ headers for later retrieval
5454
func (resolver *Cpp) ScanLibrary(lib *libraries.Library) error {
55-
cppHeaders, err := lib.SourceDir.ReadDir()
55+
cppHeaders, err := lib.SourceHeaders()
5656
if err != nil {
57-
return fmt.Errorf("reading lib src dir: %s", err)
57+
return fmt.Errorf("reading lib headers: %s", err)
5858
}
59-
cppHeaders.FilterSuffix(".h", ".hpp", ".hh")
60-
for _, cppHeaderPath := range cppHeaders {
61-
cppHeader := cppHeaderPath.Base()
59+
for _, cppHeader := range cppHeaders {
6260
l := resolver.headers[cppHeader]
6361
l.Add(lib)
6462
resolver.headers[cppHeader] = l

‎arduino/libraries/loader.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ func makeNewLibrary(libraryDir *paths.Path, location LibraryLocation) (*Library,
100100
library.Version = v
101101
}
102102

103+
if includes := libProperties.Get("includes"); includes != "" {
104+
library.sourceHeaders = commaSeparatedToList(includes)
105+
}
106+
103107
if err := addExamples(library); err != nil {
104108
return nil, errors.Errorf("scanning examples: %s", err)
105109
}

‎commands/lib/list.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func GetOutputLibrary(lib *libraries.Library) *rpc.Library {
143143
cntplat = lib.ContainerPlatform.String()
144144
}
145145

146+
libHeaders, _ := lib.SourceHeaders()
146147
return &rpc.Library{
147148
Name: lib.Name,
148149
Author: lib.Author,
@@ -167,6 +168,7 @@ func GetOutputLibrary(lib *libraries.Library) *rpc.Library {
167168
Version: lib.Version.String(),
168169
License: lib.License,
169170
Examples: lib.Examples.AsStrings(),
171+
ProvidesIncludes: libHeaders,
170172
}
171173
}
172174

‎rpc/commands/lib.pb.go‎

Lines changed: 35 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/commands/lib.proto‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ message Library {
268268
LibraryLayout layout = 25;
269269
// The example sketches provided by the library
270270
repeated string examples = 26;
271+
// Value of the `includes` field in library.properties or, if missing, the list of
272+
// include files available on the library source root directory.
273+
repeated string provides_includes = 27;
271274
}
272275

273276
enum LibraryLayout {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /