build: Clean up build.sh, add build.ps1 (#6689)

This commit is contained in:
Jakob Borg 2020-05-28 11:42:15 +01:00 committed by GitHub
parent 9c0825c0d9
commit 04ff890263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 116 deletions

20
build.ps1 Normal file
View File

@ -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
}
}

View File

@ -2,8 +2,6 @@
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'
STTRACE=${STTRACE:-}
script() { script() {
name="$1" name="$1"
shift shift
@ -15,88 +13,23 @@ build() {
} }
case "${1:-default}" in case "${1:-default}" in
default)
build
;;
clean)
build "$@"
;;
tar)
build "$@"
;;
assets)
build "$@"
;;
xdr)
build "$@"
;;
translate)
build "$@"
;;
deb)
build "$@"
;;
setup)
build "$@"
;;
test) test)
LOGGER_DISCARD=1 build test LOGGER_DISCARD=1 build test
;; ;;
bench) bench)
LOGGER_DISCARD=1 build bench | script benchfilter LOGGER_DISCARD=1 build bench
;; ;;
prerelease) prerelease)
go run script/authors.go script authors
build transifex build transifex
pushd man ; ./refresh.sh ; popd pushd man ; ./refresh.sh ; popd
git add -A gui man AUTHORS git add -A gui man AUTHORS
git commit -m 'gui, man, authors: Update docs, translations, and contributors' 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 esac

View File

@ -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()
}