Skip to content

Commit

Permalink
Upgrade go-paths / remove duplicate filter function
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Dec 19, 2023
1 parent 42e691e commit 434978c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .licenses/go/github.com/arduino/go-paths-helper.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: github.com/arduino/go-paths-helper
version: v1.10.1
version: v1.11.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/arduino/go-paths-helper
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ replace github.com/mailru/easyjson => github.com/cmaglie/easyjson v0.8.1

require (
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371
github.com/arduino/go-paths-helper v1.10.1
github.com/arduino/go-paths-helper v1.11.0
github.com/arduino/go-properties-orderedmap v1.8.0
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b
github.com/arduino/go-win32-utils v1.0.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYU
github.com/arduino/go-paths-helper v1.0.1/go.mod h1:HpxtKph+g238EJHq4geEPv9p+gl3v5YYu35Yb+w31Ck=
github.com/arduino/go-paths-helper v1.10.1 h1:j8InnhLrSeoPiOvTnZL0XMFt7l407ciTBJJJs7W9bs4=
github.com/arduino/go-paths-helper v1.10.1/go.mod h1:jcpW4wr0u69GlXhTYydsdsqAjLaYK5n7oWHfKqOG6LM=
github.com/arduino/go-paths-helper v1.11.0 h1:hkpGb9AtCTByTj2FKutuHWb3klDf4kAKL10hW+fN+oE=
github.com/arduino/go-paths-helper v1.11.0/go.mod h1:jcpW4wr0u69GlXhTYydsdsqAjLaYK5n7oWHfKqOG6LM=
github.com/arduino/go-properties-orderedmap v1.8.0 h1:wEfa6hHdpezrVOh787OmClsf/Kd8qB+zE3P2Xbrn0CQ=
github.com/arduino/go-properties-orderedmap v1.8.0/go.mod h1:DKjD2VXY/NZmlingh4lSFMEYCVubfeArCsGPGDwb2yk=
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b h1:9hDi4F2st6dbLC3y4i02zFT5quS4X6iioWifGlVwfy4=
Expand Down
19 changes: 7 additions & 12 deletions internal/arduino/builder/linker.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ import (
"github.com/arduino/go-paths-helper"
)

func filter(p *paths.PathList, filter func(*paths.Path) bool) paths.PathList {
res := (*p)[:0]
for _, path := range *p {
if filter(path) {
res = append(res, path)
}
}
return res
}

// link fixdoc
func (b *Builder) link() error {
if b.onlyUpdateCompilationDatabase {
Expand Down Expand Up @@ -64,14 +54,19 @@ func (b *Builder) link() error {
// because thery are both named spi.o.

archives := paths.NewPathList()

for _, object := range objectFiles {
archive := object.Parent().Join("objs.a")
archives.AddIfMissing(archive)
}

// Generate archive for each directory
for _, archive := range archives {
relatedObjectFiles := filter(&objectFiles, func(object *paths.Path) bool { return object.Parent().EquivalentTo(archive.Parent()) })
archiveDir := archive.Parent()
relatedObjectFiles := objectFiles.Clone()
relatedObjectFiles.Filter(func(object *paths.Path) bool {
// extract all the object files that are in the same directory of the archive
return object.Parent().EquivalentTo(archiveDir)
})
b.archiveCompiledFiles(archive.Parent(), paths.New(archive.Base()), relatedObjectFiles)
}

Expand Down

0 comments on commit 434978c

Please sign in to comment.