mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-15 17:30:44 +00:00
build: fix make generate not print changed files (#1820)
This commit is contained in:
parent
01b8fce6e3
commit
28efc50013
2 changed files with 12 additions and 7 deletions
|
|
@ -318,9 +318,14 @@ func doGenerate() {
|
||||||
)
|
)
|
||||||
pathList := []string{filepath.Join(protocPath, "bin"), protocGenGoPath, os.Getenv("PATH")}
|
pathList := []string{filepath.Join(protocPath, "bin"), protocGenGoPath, os.Getenv("PATH")}
|
||||||
|
|
||||||
|
excludes := []string{"tests/testdata", "build/cache", ".git"}
|
||||||
|
for i := range excludes {
|
||||||
|
excludes[i] = filepath.FromSlash(excludes[i])
|
||||||
|
}
|
||||||
|
|
||||||
for _, mod := range goModules {
|
for _, mod := range goModules {
|
||||||
// Compute the origin hashes of all the files
|
// Compute the origin hashes of all the files
|
||||||
hashes, err := build.HashFolder(mod, []string{"tests/testdata", "build/cache", ".git"})
|
hashes, err := build.HashFolder(mod, excludes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Error computing hashes", "err", err)
|
log.Fatal("Error computing hashes", "err", err)
|
||||||
}
|
}
|
||||||
|
|
@ -330,7 +335,7 @@ func doGenerate() {
|
||||||
c.Dir = mod
|
c.Dir = mod
|
||||||
build.MustRun(c)
|
build.MustRun(c)
|
||||||
// Check if generate file hashes have changed
|
// Check if generate file hashes have changed
|
||||||
generated, err := build.HashFolder(mod, []string{"tests/testdata", "build/cache", ".git"})
|
generated, err := build.HashFolder(mod, excludes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error re-computing hashes: %v", err)
|
log.Fatalf("Error re-computing hashes: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,19 +22,19 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// HashFolder iterates all files under the given directory, computing the hash
|
// HashFolder iterates all files under the given directory, computing the hash
|
||||||
// of each.
|
// of each.
|
||||||
func HashFolder(folder string, exlude []string) (map[string][32]byte, error) {
|
func HashFolder(folder string, excludes []string) (map[string][32]byte, error) {
|
||||||
res := make(map[string][32]byte)
|
res := make(map[string][32]byte)
|
||||||
err := filepath.WalkDir(folder, func(path string, d os.DirEntry, _ error) error {
|
err := filepath.WalkDir(folder, func(path string, d os.DirEntry, _ error) error {
|
||||||
// Skip anything that's exluded or not a regular file
|
// Skip anything that's excluded or not a regular file
|
||||||
for _, skip := range exlude {
|
if slices.Contains(excludes, path) {
|
||||||
if strings.HasPrefix(path, filepath.FromSlash(skip)) {
|
if d.IsDir() {
|
||||||
return filepath.SkipDir
|
return filepath.SkipDir
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
if !d.Type().IsRegular() {
|
if !d.Type().IsRegular() {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue