@@ -23,6 +23,7 @@ import (
23
23
"fmt"
24
24
"os/exec"
25
25
"regexp"
26
+ "slices"
26
27
"strings"
27
28
"time"
28
29
@@ -59,6 +60,7 @@ type SketchLibrariesDetector struct {
59
60
logger * logger.BuilderLogger
60
61
diagnosticStore * diagnostics.Store
61
62
preRunner * runner.Runner
63
+ detectedChangeInLibraries bool
62
64
}
63
65
64
66
// NewSketchLibrariesDetector todo
@@ -174,6 +176,12 @@ func (l *SketchLibrariesDetector) IncludeFolders() paths.PathList {
174
176
return l .includeFolders
175
177
}
176
178
179
+ // IncludeFoldersChanged returns true if the include folders list changed
180
+ // from the previous compile.
181
+ func (l * SketchLibrariesDetector ) IncludeFoldersChanged () bool {
182
+ return l .detectedChangeInLibraries
183
+ }
184
+
177
185
// addIncludeFolder add the given folder to the include path.
178
186
func (l * SketchLibrariesDetector ) addIncludeFolder (folder * paths.Path ) {
179
187
l .includeFolders = append (l .includeFolders , folder )
@@ -219,17 +227,21 @@ func (l *SketchLibrariesDetector) findIncludes(
219
227
platformArch string ,
220
228
jobs int ,
221
229
) error {
222
- librariesResolutionCache := buildPath .Join ("libraries.cache" )
223
- if l .useCachedLibrariesResolution && librariesResolutionCache .Exist () {
224
- d , err := librariesResolutionCache .ReadFile ()
230
+ librariesResolutionCachePath := buildPath .Join ("libraries.cache" )
231
+ var cachedIncludeFolders paths.PathList
232
+ if librariesResolutionCachePath .Exist () {
233
+ d , err := librariesResolutionCachePath .ReadFile ()
225
234
if err != nil {
226
235
return err
227
236
}
228
- if err := json .Unmarshal (d , & l . includeFolders ); err != nil {
237
+ if err := json .Unmarshal (d , & cachedIncludeFolders ); err != nil {
229
238
return err
230
239
}
240
+ }
241
+ if l .useCachedLibrariesResolution && librariesResolutionCachePath .Exist () {
242
+ l .includeFolders = cachedIncludeFolders
231
243
if l .logger .Verbose () {
232
- l .logger .Info ("Using cached library discovery: " + librariesResolutionCache .String ())
244
+ l .logger .Info ("Using cached library discovery: " + librariesResolutionCachePath .String ())
233
245
}
234
246
return nil
235
247
}
@@ -301,10 +313,12 @@ func (l *SketchLibrariesDetector) findIncludes(
301
313
302
314
if d , err := json .Marshal (l .includeFolders ); err != nil {
303
315
return err
304
- } else if err := librariesResolutionCache .WriteFile (d ); err != nil {
316
+ } else if err := librariesResolutionCachePath .WriteFile (d ); err != nil {
305
317
return err
306
318
}
307
-
319
+ l .detectedChangeInLibraries = ! slices .Equal (
320
+ cachedIncludeFolders .AsStrings (),
321
+ l .includeFolders .AsStrings ())
308
322
return nil
309
323
}
310
324
0 commit comments