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

Appearance settings

Commit a0a703f

Browse filesBrowse files
committed
fix: libraries are recompiled if the list of include paths changes
1 parent a9cf210 commit a0a703f
Copy full SHA for a0a703f

File tree

2 files changed

+29
-7
lines changed
Filter options

2 files changed

+29
-7
lines changed

‎internal/arduino/builder/builder.go

Copy file name to clipboardExpand all lines: internal/arduino/builder/builder.go
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,14 @@ func (b *Builder) preprocess() error {
327327
if err != nil {
328328
return err
329329
}
330+
if b.libsDetector.IncludeFoldersChanged() && b.librariesBuildPath.Exist() {
331+
if b.logger.Verbose() {
332+
b.logger.Info(i18n.Tr("The list of included libraries has been changed... rebuilding all libraries."))
333+
}
334+
if err := b.librariesBuildPath.RemoveAll(); err != nil {
335+
return err
336+
}
337+
}
330338
b.Progress.CompleteStep()
331339

332340
b.warnAboutArchIncompatibleLibraries(b.libsDetector.ImportedLibraries())

‎internal/arduino/builder/internal/detector/detector.go

Copy file name to clipboardExpand all lines: internal/arduino/builder/internal/detector/detector.go
+21-7Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"fmt"
2424
"os/exec"
2525
"regexp"
26+
"slices"
2627
"strings"
2728
"time"
2829

@@ -59,6 +60,7 @@ type SketchLibrariesDetector struct {
5960
logger *logger.BuilderLogger
6061
diagnosticStore *diagnostics.Store
6162
preRunner *runner.Runner
63+
detectedChangeInLibraries bool
6264
}
6365

6466
// NewSketchLibrariesDetector todo
@@ -174,6 +176,12 @@ func (l *SketchLibrariesDetector) IncludeFolders() paths.PathList {
174176
return l.includeFolders
175177
}
176178

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+
177185
// addIncludeFolder add the given folder to the include path.
178186
func (l *SketchLibrariesDetector) addIncludeFolder(folder *paths.Path) {
179187
l.includeFolders = append(l.includeFolders, folder)
@@ -219,17 +227,21 @@ func (l *SketchLibrariesDetector) findIncludes(
219227
platformArch string,
220228
jobs int,
221229
) 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()
225234
if err != nil {
226235
return err
227236
}
228-
if err := json.Unmarshal(d, &l.includeFolders); err != nil {
237+
if err := json.Unmarshal(d, &cachedIncludeFolders); err != nil {
229238
return err
230239
}
240+
}
241+
if l.useCachedLibrariesResolution && librariesResolutionCachePath.Exist() {
242+
l.includeFolders = cachedIncludeFolders
231243
if l.logger.VerbosityLevel() == logger.VerbosityVerbose {
232-
l.logger.Info("Using cached library discovery: " + librariesResolutionCache.String())
244+
l.logger.Info("Using cached library discovery: " + librariesResolutionCachePath.String())
233245
}
234246
return nil
235247
}
@@ -301,10 +313,12 @@ func (l *SketchLibrariesDetector) findIncludes(
301313

302314
if d, err := json.Marshal(l.includeFolders); err != nil {
303315
return err
304-
} else if err := librariesResolutionCache.WriteFile(d); err != nil {
316+
} else if err := librariesResolutionCachePath.WriteFile(d); err != nil {
305317
return err
306318
}
307-
319+
l.detectedChangeInLibraries = !slices.Equal(
320+
cachedIncludeFolders.AsStrings(),
321+
l.includeFolders.AsStrings())
308322
return nil
309323
}
310324

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.