mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
build: fix for Go 1.24, which does not support the "work" pattern
This commit is contained in:
parent
c38a49f13e
commit
659035036d
1 changed files with 37 additions and 22 deletions
59
build/ci.go
59
build/ci.go
|
|
@ -322,9 +322,9 @@ func doTest(cmdline []string) {
|
||||||
gotest.Args = append(gotest.Args, "-short")
|
gotest.Args = append(gotest.Args, "-short")
|
||||||
}
|
}
|
||||||
|
|
||||||
packages := []string{"work"}
|
packages := flag.CommandLine.Args()
|
||||||
if len(flag.CommandLine.Args()) > 0 {
|
if len(packages) == 0 {
|
||||||
packages = flag.CommandLine.Args()
|
packages = workspacePackagePatterns()
|
||||||
}
|
}
|
||||||
gotest.Args = append(gotest.Args, packages...)
|
gotest.Args = append(gotest.Args, packages...)
|
||||||
build.MustRun(gotest)
|
build.MustRun(gotest)
|
||||||
|
|
@ -364,7 +364,7 @@ func doCheckGenerate() {
|
||||||
protocPath = downloadProtoc(*cachedir)
|
protocPath = downloadProtoc(*cachedir)
|
||||||
protocGenGoPath = downloadProtocGenGo(*cachedir)
|
protocGenGoPath = downloadProtocGenGo(*cachedir)
|
||||||
)
|
)
|
||||||
c := tc.Go("generate", "work")
|
c := tc.Go("generate", workspacePackagePatterns()...)
|
||||||
pathList := []string{filepath.Join(protocPath, "bin"), protocGenGoPath, os.Getenv("PATH")}
|
pathList := []string{filepath.Join(protocPath, "bin"), protocGenGoPath, os.Getenv("PATH")}
|
||||||
c.Env = append(c.Env, "PATH="+strings.Join(pathList, string(os.PathListSeparator)))
|
c.Env = append(c.Env, "PATH="+strings.Join(pathList, string(os.PathListSeparator)))
|
||||||
build.MustRun(c)
|
build.MustRun(c)
|
||||||
|
|
@ -422,30 +422,17 @@ func doCheckBadDeps() {
|
||||||
func doLint(cmdline []string) {
|
func doLint(cmdline []string) {
|
||||||
var (
|
var (
|
||||||
cachedir = flag.String("cachedir", "./build/cache", "directory for caching golangci-lint binary.")
|
cachedir = flag.String("cachedir", "./build/cache", "directory for caching golangci-lint binary.")
|
||||||
tc = new(build.GoToolchain)
|
|
||||||
)
|
)
|
||||||
flag.CommandLine.Parse(cmdline)
|
flag.CommandLine.Parse(cmdline)
|
||||||
|
|
||||||
packages := flag.CommandLine.Args()
|
packages := flag.CommandLine.Args()
|
||||||
if len(packages) == 0 {
|
if len(packages) == 0 {
|
||||||
// Get module directories in workspace.
|
// Get module directories in workspace.
|
||||||
listing, err := tc.Go("list", "-m").Output()
|
packages = []string{"./..."}
|
||||||
if err != nil {
|
modules := workspaceModules()
|
||||||
log.Fatalf("go list failed:", err)
|
for _, m := range modules[1:] {
|
||||||
}
|
dir := strings.TrimPrefix(m, modules[0])
|
||||||
var mainModule []byte
|
packages = append(packages, "."+dir+"/...")
|
||||||
for i, m := range bytes.Split(listing, []byte("\n")) {
|
|
||||||
m = bytes.TrimSpace(m)
|
|
||||||
if i == 0 {
|
|
||||||
mainModule = m
|
|
||||||
packages = append(packages, "./...")
|
|
||||||
} else if len(m) > 0 {
|
|
||||||
dir := string(bytes.TrimPrefix(m, mainModule))
|
|
||||||
packages = append(packages, "."+dir+"/...")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(packages) == 0 {
|
|
||||||
log.Fatal("no packages found")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1189,3 +1176,31 @@ func doSanityCheck() {
|
||||||
csdb := download.MustLoadChecksums("build/checksums.txt")
|
csdb := download.MustLoadChecksums("build/checksums.txt")
|
||||||
csdb.DownloadAndVerifyAll()
|
csdb.DownloadAndVerifyAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// workspaceModules lists the module paths in the current work.
|
||||||
|
func workspaceModules() []string {
|
||||||
|
listing, err := new(build.GoToolchain).Go("list", "-m").Output()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("go list failed:", err)
|
||||||
|
}
|
||||||
|
var modules []string
|
||||||
|
for _, m := range bytes.Split(listing, []byte("\n")) {
|
||||||
|
m = bytes.TrimSpace(m)
|
||||||
|
if len(m) > 0 {
|
||||||
|
modules = append(modules, string(m))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(modules) == 0 {
|
||||||
|
panic("no modules found")
|
||||||
|
}
|
||||||
|
return modules
|
||||||
|
}
|
||||||
|
|
||||||
|
func workspacePackagePatterns() []string {
|
||||||
|
modules := workspaceModules()
|
||||||
|
patterns := make([]string, len(modules))
|
||||||
|
for i, m := range modules {
|
||||||
|
patterns[i] = m + "/..."
|
||||||
|
}
|
||||||
|
return patterns
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue