forked from cerc-io/plugeth
build: unify vendor skipping logic
This fixes a recent bug where 'make geth' built everything instead of just geth.
This commit is contained in:
parent
11e7a712f4
commit
e7911ad9ea
29
build/ci.go
29
build/ci.go
@ -173,19 +173,7 @@ func doInstall(cmdline []string) {
|
|||||||
if flag.NArg() > 0 {
|
if flag.NArg() > 0 {
|
||||||
packages = flag.Args()
|
packages = flag.Args()
|
||||||
}
|
}
|
||||||
|
packages = build.ExpandPackagesNoVendor(packages)
|
||||||
// Resolve ./... manually and remove vendor/bazil/fuse (fuse is not in windows)
|
|
||||||
out, err := goTool("list", "./...").CombinedOutput()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("package listing failed: %v\n%s", err, string(out))
|
|
||||||
}
|
|
||||||
packages = []string{}
|
|
||||||
for _, line := range strings.Split(string(out), "\n") {
|
|
||||||
if !strings.Contains(line, "vendor") {
|
|
||||||
packages = append(packages, strings.TrimSpace(line))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if *arch == "" || *arch == runtime.GOARCH {
|
if *arch == "" || *arch == runtime.GOARCH {
|
||||||
goinstall := goTool("install", buildFlags(env)...)
|
goinstall := goTool("install", buildFlags(env)...)
|
||||||
@ -284,19 +272,8 @@ func doTest(cmdline []string) {
|
|||||||
if len(flag.CommandLine.Args()) > 0 {
|
if len(flag.CommandLine.Args()) > 0 {
|
||||||
packages = flag.CommandLine.Args()
|
packages = flag.CommandLine.Args()
|
||||||
}
|
}
|
||||||
if len(packages) == 1 && packages[0] == "./..." {
|
packages = build.ExpandPackagesNoVendor(packages)
|
||||||
// Resolve ./... manually since go vet will fail on vendored stuff
|
|
||||||
out, err := goTool("list", "./...").CombinedOutput()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("package listing failed: %v\n%s", err, string(out))
|
|
||||||
}
|
|
||||||
packages = []string{}
|
|
||||||
for _, line := range strings.Split(string(out), "\n") {
|
|
||||||
if !strings.Contains(line, "vendor") {
|
|
||||||
packages = append(packages, strings.TrimSpace(line))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Run analysis tools before the tests.
|
// Run analysis tools before the tests.
|
||||||
if *vet {
|
if *vet {
|
||||||
build.MustRun(goTool("vet", packages...))
|
build.MustRun(goTool("vet", packages...))
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
@ -136,3 +137,30 @@ func CopyFile(dst, src string, mode os.FileMode) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExpandPackagesNoVendor expands a cmd/go import path pattern, skipping
|
||||||
|
// vendored packages.
|
||||||
|
func ExpandPackagesNoVendor(patterns []string) []string {
|
||||||
|
expand := false
|
||||||
|
for _, pkg := range patterns {
|
||||||
|
if strings.Contains(pkg, "...") {
|
||||||
|
expand = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if expand {
|
||||||
|
args := append([]string{"list"}, patterns...)
|
||||||
|
cmd := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), args...)
|
||||||
|
out, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("package listing failed: %v\n%s", err, string(out))
|
||||||
|
}
|
||||||
|
var packages []string
|
||||||
|
for _, line := range strings.Split(string(out), "\n") {
|
||||||
|
if !strings.Contains(line, "/vendor/") {
|
||||||
|
packages = append(packages, strings.TrimSpace(line))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return packages
|
||||||
|
}
|
||||||
|
return patterns
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user