From 04ff8902636071f5b91e339e1490bacb3811bc54 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Thu, 28 May 2020 11:42:15 +0100 Subject: [PATCH] build: Clean up build.sh, add build.ps1 (#6689) --- build.ps1 | 20 ++++++++++++ build.sh | 73 ++----------------------------------------- script/benchfilter.go | 46 --------------------------- 3 files changed, 23 insertions(+), 116 deletions(-) create mode 100644 build.ps1 delete mode 100644 script/benchfilter.go diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 000000000..97d991cf7 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,20 @@ +function build { + go run build.go @args +} + +$cmd, $rest = $args +switch ($cmd) { + "test" { + $env:LOGGER_DISCARD=1 + build test + } + + "bench" { + $env:LOGGER_DISCARD=1 + build bench + } + + default { + build @rest + } +} diff --git a/build.sh b/build.sh index 23f8d221d..6251b71a6 100755 --- a/build.sh +++ b/build.sh @@ -2,8 +2,6 @@ set -euo pipefail IFS=$'\n\t' -STTRACE=${STTRACE:-} - script() { name="$1" shift @@ -15,88 +13,23 @@ build() { } case "${1:-default}" in - default) - build - ;; - - clean) - build "$@" - ;; - - tar) - build "$@" - ;; - - assets) - build "$@" - ;; - - xdr) - build "$@" - ;; - - translate) - build "$@" - ;; - - deb) - build "$@" - ;; - - setup) - build "$@" - ;; - test) LOGGER_DISCARD=1 build test ;; bench) - LOGGER_DISCARD=1 build bench | script benchfilter + LOGGER_DISCARD=1 build bench ;; prerelease) - go run script/authors.go + script authors build transifex pushd man ; ./refresh.sh ; popd git add -A gui man AUTHORS git commit -m 'gui, man, authors: Update docs, translations, and contributors' ;; - noupgrade) - build -no-upgrade tar - ;; - - all) - platforms=( - darwin-amd64 dragonfly-amd64 freebsd-amd64 linux-amd64 netbsd-amd64 openbsd-amd64 solaris-amd64 windows-amd64 - freebsd-386 linux-386 netbsd-386 openbsd-386 windows-386 - linux-arm linux-arm64 linux-ppc64 linux-ppc64le - ) - - for plat in "${platforms[@]}"; do - echo Building "$plat" - - goos="${plat%-*}" - goarch="${plat#*-}" - dist="tar" - - if [[ $goos == "windows" ]]; then - dist="zip" - fi - - build -goos "$goos" -goarch "$goarch" "$dist" - echo - done - ;; - - test-xunit) - - (GOPATH="$(pwd)/Godeps/_workspace:$GOPATH" go test -v -race ./lib/... ./cmd/... || true) > tests.out - go2xunit -output tests.xml -fail < tests.out - ;; - *) - echo "Unknown build command $1" + build "$@" ;; esac diff --git a/script/benchfilter.go b/script/benchfilter.go deleted file mode 100644 index c543f518a..000000000 --- a/script/benchfilter.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2015 The Syncthing Authors. -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this file, -// You can obtain one at https://mozilla.org/MPL/2.0/. - -// +build ignore - -// Neatly format benchmarking output which otherwise looks like crap. -package main - -import ( - "bufio" - "fmt" - "os" - "regexp" - "strings" - "text/tabwriter" -) - -var ( - benchRe = regexp.MustCompile(`^(Bench[^\s]+)\s+(\d+)\s+(\d+ ns/op)\s*(\d+ B/op)?\s*(\d+ allocs/op)?`) -) - -func main() { - tw := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', 0) - br := bufio.NewScanner(os.Stdin) - n := 0 - - for br.Scan() { - line := br.Text() - - if match := benchRe.FindStringSubmatch(line); match != nil { - n++ - for i := range match[2:] { - match[2+i] = fmt.Sprintf("%16s", match[2+i]) - } - tw.Write([]byte(strings.Join(match[1:], "\t") + "\n")) - } else if n > 0 && strings.HasPrefix(line, "ok") { - n = 0 - tw.Flush() - fmt.Printf("%s\n\n", line) - } - } - tw.Flush() -}