diff options
author | Jakob Borg <jakob@nym.se> | 2016-06-08 16:15:45 +0000 |
---|---|---|
committer | Audrius Butkevicius <audrius.butkevicius@gmail.com> | 2016-06-08 16:15:45 +0000 |
commit | b4e2914b70f70d69f17e3f7227ee08665baa1a09 (patch) | |
tree | 53c15be4c5272ece2c3fca2a29e026f0378e5342 | |
parent | 09b73485957d4ab4d762bc3491ad85354631f69e (diff) |
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
-rw-r--r-- | build.go | 33 |
1 files changed, 31 insertions, 2 deletions
@@ -39,6 +39,7 @@ var ( version string goVersion float64 race bool + debug = os.Getenv("BUILDDEBUG") != "" ) type target struct { @@ -154,6 +155,13 @@ func main() { log.SetOutput(os.Stdout) log.SetFlags(0) + if debug { + t0 := time.Now() + defer func() { + log.Println("... build completed in", time.Since(t0)) + }() + } + if os.Getenv("GOPATH") == "" { setGoPath() } @@ -259,6 +267,8 @@ func runCommand(cmd string, target target) { lint(".") lint("./cmd/...") lint("./lib/...") + + case "metalint": if isGometalinterInstalled() { dirs := []string{".", "./cmd/...", "./lib/..."} gometalinter("deadcode", dirs, "test/util.go") @@ -744,13 +754,26 @@ func archiveName(target target) string { } 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...) bs, err := ecmd.CombinedOutput() return bytes.TrimSpace(bs), err } 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.Stdout = os.Stdout ecmd.Stderr = os.Stderr @@ -761,7 +784,13 @@ func runPrint(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) if err != nil { log.Fatal(err) |