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 f32315f

Browse files
committed
Build dir cleanup keeps lib-discovery output files
1 parent 096d8fa commit f32315f

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

‎internal/arduino/builder/builder.go‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"io"
2323
"os"
2424
"path/filepath"
25+
"sort"
2526
"strings"
2627

2728
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/compilation"
@@ -331,7 +332,7 @@ func (b *Builder) preprocess() error {
331332
if b.logger.VerbosityLevel() == logger.VerbosityVerbose {
332333
b.logger.Info(i18n.Tr("The list of included libraries has been changed... rebuilding all libraries."))
333334
}
334-
if err := b.librariesBuildPath.RemoveAll(); err != nil {
335+
if err := b.removeBuildPathExecptLibsdiscoveryFiles(b.librariesBuildPath); err != nil {
335336
return err
336337
}
337338
}
@@ -544,3 +545,28 @@ func (b *Builder) execCommand(command *paths.Process) error {
544545

545546
return command.Wait()
546547
}
548+
549+
func (b *Builder) removeBuildPathExecptLibsdiscoveryFiles(pathToRemove *paths.Path) error {
550+
filesToRemove, err := pathToRemove.ReadDirRecursiveFiltered(nil,
551+
paths.FilterOutDirectories(),
552+
paths.FilterOutSuffixes(".libsdetect.d"))
553+
if err != nil {
554+
return err
555+
}
556+
for _, f := range filesToRemove {
557+
if err := f.Remove(); err != nil {
558+
return err
559+
}
560+
}
561+
562+
dirsToRemove, err := pathToRemove.ReadDirRecursiveFiltered(nil, paths.FilterDirectories())
563+
if err != nil {
564+
return err
565+
}
566+
// Remove directories in reverse order (deepest first)
567+
sort.Slice(dirsToRemove, func(i, j int) bool { return len(dirsToRemove[i].String()) > len(dirsToRemove[j].String()) })
568+
for _, d := range dirsToRemove {
569+
_ = d.Remove()
570+
}
571+
return nil
572+
}

0 commit comments

Comments
(0)

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