Skip to content

Commit 9e5276e

Browse files
committed
Upgrade go-paths / remove duplicate filter function
1 parent cdd7b75 commit 9e5276e

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

Diff for: .licenses/go/github.com/arduino/go-paths-helper.dep.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: github.com/arduino/go-paths-helper
3-
version: v1.10.1
3+
version: v1.11.0
44
type: go
55
summary:
66
homepage: https://pkg.go.dev/github.com/arduino/go-paths-helper

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ replace github.com/mailru/easyjson => github.com/cmaglie/easyjson v0.8.1
77

88
require (
99
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371
10-
github.com/arduino/go-paths-helper v1.10.1
10+
github.com/arduino/go-paths-helper v1.11.0
1111
github.com/arduino/go-properties-orderedmap v1.8.0
1212
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b
1313
github.com/arduino/go-win32-utils v1.0.0

Diff for: go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ
1111
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
1212
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
1313
github.com/arduino/go-paths-helper v1.0.1/go.mod h1:HpxtKph+g238EJHq4geEPv9p+gl3v5YYu35Yb+w31Ck=
14-
github.com/arduino/go-paths-helper v1.10.1 h1:j8InnhLrSeoPiOvTnZL0XMFt7l407ciTBJJJs7W9bs4=
15-
github.com/arduino/go-paths-helper v1.10.1/go.mod h1:jcpW4wr0u69GlXhTYydsdsqAjLaYK5n7oWHfKqOG6LM=
14+
github.com/arduino/go-paths-helper v1.11.0 h1:hkpGb9AtCTByTj2FKutuHWb3klDf4kAKL10hW+fN+oE=
15+
github.com/arduino/go-paths-helper v1.11.0/go.mod h1:jcpW4wr0u69GlXhTYydsdsqAjLaYK5n7oWHfKqOG6LM=
1616
github.com/arduino/go-properties-orderedmap v1.8.0 h1:wEfa6hHdpezrVOh787OmClsf/Kd8qB+zE3P2Xbrn0CQ=
1717
github.com/arduino/go-properties-orderedmap v1.8.0/go.mod h1:DKjD2VXY/NZmlingh4lSFMEYCVubfeArCsGPGDwb2yk=
1818
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b h1:9hDi4F2st6dbLC3y4i02zFT5quS4X6iioWifGlVwfy4=

Diff for: internal/arduino/builder/linker.go

+7-12
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ import (
2222
"github.com/arduino/go-paths-helper"
2323
)
2424

25-
func filter(p *paths.PathList, filter func(*paths.Path) bool) paths.PathList {
26-
res := (*p)[:0]
27-
for _, path := range *p {
28-
if filter(path) {
29-
res = append(res, path)
30-
}
31-
}
32-
return res
33-
}
34-
3525
// link fixdoc
3626
func (b *Builder) link() error {
3727
if b.onlyUpdateCompilationDatabase {
@@ -64,14 +54,19 @@ func (b *Builder) link() error {
6454
// because thery are both named spi.o.
6555

6656
archives := paths.NewPathList()
67-
6857
for _, object := range objectFiles {
6958
archive := object.Parent().Join("objs.a")
7059
archives.AddIfMissing(archive)
7160
}
7261

62+
// Generate archive for each directory
7363
for _, archive := range archives {
74-
relatedObjectFiles := filter(&objectFiles, func(object *paths.Path) bool { return object.Parent().EquivalentTo(archive.Parent()) })
64+
archiveDir := archive.Parent()
65+
relatedObjectFiles := objectFiles.Clone()
66+
relatedObjectFiles.Filter(func(object *paths.Path) bool {
67+
// extract all the object files that are in the same directory of the archive
68+
return object.Parent().EquivalentTo(archiveDir)
69+
})
7570
b.archiveCompiledFiles(archive.Parent(), paths.New(archive.Base()), relatedObjectFiles)
7671
}
7772

0 commit comments

Comments
 (0)