|
16 | 16 | package libraries
|
17 | 17 |
|
18 | 18 | import (
|
| 19 | + "fmt" |
| 20 | + |
19 | 21 | "github.com/arduino/arduino-cli/arduino/cores"
|
20 | 22 | paths "github.com/arduino/go-paths-helper"
|
21 | 23 | properties "github.com/arduino/go-properties-orderedmap"
|
@@ -71,6 +73,7 @@ type Library struct {
|
71 | 73 | License string
|
72 | 74 | Properties *properties.Map
|
73 | 75 | Examples paths.PathList
|
| 76 | + sourceHeaders []string |
74 | 77 | }
|
75 | 78 |
|
76 | 79 | func (library *Library) String() string {
|
@@ -153,3 +156,20 @@ func (library *Library) LocationPriorityFor(platformRelease, refPlatformRelease
|
153 | 156 | }
|
154 | 157 | return 0
|
155 | 158 | }
|
| 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 | +} |
0 commit comments