build: Move metalint to a separate build step (and add build step timings)
I run a lot of builds. They're quite slow now:
jb@syno:~/s/g/s/syncthing $ BUILDDEBUG=1 ./build.sh
... snipped commands ...
runError: gometalinter --disable-all --deadline=60s --enable=varcheck . ./cmd/... ./lib/...
... in 13.00592726s
... build completed in 15.392265235s
That's 15 s total build time, 13 s of which is the varcheck call. The
build server is welcome to run it, but I don't want to on each build. :)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3285
This commit is contained in:
parent
09b7348595
commit
b4e2914b70
33
build.go
33
build.go
@ -39,6 +39,7 @@ var (
|
|||||||
version string
|
version string
|
||||||
goVersion float64
|
goVersion float64
|
||||||
race bool
|
race bool
|
||||||
|
debug = os.Getenv("BUILDDEBUG") != ""
|
||||||
)
|
)
|
||||||
|
|
||||||
type target struct {
|
type target struct {
|
||||||
@ -154,6 +155,13 @@ func main() {
|
|||||||
log.SetOutput(os.Stdout)
|
log.SetOutput(os.Stdout)
|
||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
|
|
||||||
|
if debug {
|
||||||
|
t0 := time.Now()
|
||||||
|
defer func() {
|
||||||
|
log.Println("... build completed in", time.Since(t0))
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
if os.Getenv("GOPATH") == "" {
|
if os.Getenv("GOPATH") == "" {
|
||||||
setGoPath()
|
setGoPath()
|
||||||
}
|
}
|
||||||
@ -259,6 +267,8 @@ func runCommand(cmd string, target target) {
|
|||||||
lint(".")
|
lint(".")
|
||||||
lint("./cmd/...")
|
lint("./cmd/...")
|
||||||
lint("./lib/...")
|
lint("./lib/...")
|
||||||
|
|
||||||
|
case "metalint":
|
||||||
if isGometalinterInstalled() {
|
if isGometalinterInstalled() {
|
||||||
dirs := []string{".", "./cmd/...", "./lib/..."}
|
dirs := []string{".", "./cmd/...", "./lib/..."}
|
||||||
gometalinter("deadcode", dirs, "test/util.go")
|
gometalinter("deadcode", dirs, "test/util.go")
|
||||||
@ -744,13 +754,26 @@ func archiveName(target target) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runError(cmd string, args ...string) ([]byte, error) {
|
func runError(cmd string, args ...string) ([]byte, error) {
|
||||||
|
if debug {
|
||||||
|
t0 := time.Now()
|
||||||
|
log.Println("runError:", cmd, strings.Join(args, " "))
|
||||||
|
defer func() {
|
||||||
|
log.Println("... in", time.Since(t0))
|
||||||
|
}()
|
||||||
|
}
|
||||||
ecmd := exec.Command(cmd, args...)
|
ecmd := exec.Command(cmd, args...)
|
||||||
bs, err := ecmd.CombinedOutput()
|
bs, err := ecmd.CombinedOutput()
|
||||||
return bytes.TrimSpace(bs), err
|
return bytes.TrimSpace(bs), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func runPrint(cmd string, args ...string) {
|
func runPrint(cmd string, args ...string) {
|
||||||
log.Println(cmd, strings.Join(args, " "))
|
if debug {
|
||||||
|
t0 := time.Now()
|
||||||
|
log.Println("runPrint:", cmd, strings.Join(args, " "))
|
||||||
|
defer func() {
|
||||||
|
log.Println("... in", time.Since(t0))
|
||||||
|
}()
|
||||||
|
}
|
||||||
ecmd := exec.Command(cmd, args...)
|
ecmd := exec.Command(cmd, args...)
|
||||||
ecmd.Stdout = os.Stdout
|
ecmd.Stdout = os.Stdout
|
||||||
ecmd.Stderr = os.Stderr
|
ecmd.Stderr = os.Stderr
|
||||||
@ -761,7 +784,13 @@ func runPrint(cmd string, args ...string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runPipe(file, cmd string, args ...string) {
|
func runPipe(file, cmd string, args ...string) {
|
||||||
log.Println(cmd, strings.Join(args, " "), ">", file)
|
if debug {
|
||||||
|
t0 := time.Now()
|
||||||
|
log.Println("runPipe:", cmd, strings.Join(args, " "))
|
||||||
|
defer func() {
|
||||||
|
log.Println("... in", time.Since(t0))
|
||||||
|
}()
|
||||||
|
}
|
||||||
fd, err := os.Create(file)
|
fd, err := os.Create(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user