2017-11-18 19:11:14 +01:00
|
|
|
#!/bin/bash
|
2017-11-12 16:27:10 +01:00
|
|
|
set -e
|
2017-11-12 16:15:12 +01:00
|
|
|
|
2019-09-03 14:45:18 +02:00
|
|
|
|
2017-11-18 19:11:14 +01:00
|
|
|
if tty -s; then
|
2017-11-18 17:02:43 +01:00
|
|
|
bold=$(tput bold)
|
|
|
|
normal=$(tput sgr0)
|
|
|
|
else
|
|
|
|
bold=""
|
|
|
|
normal=""
|
|
|
|
fi
|
2017-11-12 16:15:12 +01:00
|
|
|
|
|
|
|
step() {
|
|
|
|
echo "${bold}$1${normal}"
|
|
|
|
}
|
|
|
|
|
2017-11-19 12:32:25 +01:00
|
|
|
if ! type go >/dev/null; then
|
2017-11-18 19:11:14 +01:00
|
|
|
step "go binary not installed or not in \$PATH" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-11-12 16:15:12 +01:00
|
|
|
if [ -z "$GOPATH" ]; then
|
2020-08-31 16:34:29 +02:00
|
|
|
step "Your GOPATH is not configured correctly" 1>&2
|
2017-11-12 16:15:12 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-08-31 16:34:29 +02:00
|
|
|
if ! (echo "$PATH" | grep "${GOPATH}/bin" > /dev/null); then
|
|
|
|
step "GOPATH/bin is not in your PATH (it should be towards the start of it)"
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-11-18 19:11:14 +01:00
|
|
|
|
2018-12-01 14:09:32 +01:00
|
|
|
godep() {
|
2019-10-26 13:55:03 +02:00
|
|
|
step "install build dependencies (versions pinned in build/go.mod and build/tools.go)"
|
|
|
|
pushd "$(dirname "${BASH_SOURCE[0]}")"/build
|
2019-09-03 14:45:18 +02:00
|
|
|
set -x
|
|
|
|
export GO111MODULE=on # otherwise, a checkout of this repo in GOPATH will disable modules on Go 1.12 and earlier
|
|
|
|
go build -v -mod=readonly -o "$GOPATH/bin/stringer" golang.org/x/tools/cmd/stringer
|
|
|
|
go build -v -mod=readonly -o "$GOPATH/bin/protoc-gen-go" github.com/golang/protobuf/protoc-gen-go
|
|
|
|
go build -v -mod=readonly -o "$GOPATH/bin/enumer" github.com/alvaroloes/enumer
|
|
|
|
go build -v -mod=readonly -o "$GOPATH/bin/goimports" golang.org/x/tools/cmd/goimports
|
|
|
|
go build -v -mod=readonly -o "$GOPATH/bin/golangci-lint" github.com/golangci/golangci-lint/cmd/golangci-lint
|
2020-05-24 17:43:42 +02:00
|
|
|
go build -v -mod=readonly -o "$GOPATH/bin/gocovmerge" github.com/wadey/gocovmerge
|
2019-09-03 14:45:18 +02:00
|
|
|
set +x
|
2019-10-26 13:55:03 +02:00
|
|
|
popd
|
2020-05-24 17:43:42 +02:00
|
|
|
if ! type stringer || ! type protoc-gen-go || ! type enumer || ! type goimports || ! type golangci-lint || ! type gocovmerge; then
|
2018-12-01 14:09:32 +01:00
|
|
|
echo "Installed dependencies but can't find them in \$PATH, adjust it to contain \$GOPATH/bin" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-11-18 19:11:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
docdep() {
|
|
|
|
if ! type pip3; then
|
|
|
|
step "pip3 binary not installed or not in \$PATH" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
step "Installing doc build dependencies"
|
2020-08-31 16:34:29 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local reqpath="$(dirname "${BASH_SOURCE[0]}")/docs/requirements.txt"
|
|
|
|
if [ -n "$ZREPL_LAZY_DOCS_REQPATH" ]; then
|
2017-11-18 19:11:14 +01:00
|
|
|
reqpath="$ZREPL_LAZY_DOCS_REQPATH"
|
|
|
|
fi
|
|
|
|
pip3 install -r "$reqpath"
|
|
|
|
}
|
|
|
|
|
|
|
|
release() {
|
|
|
|
step "Making release"
|
|
|
|
make release
|
|
|
|
}
|
2017-11-12 16:15:12 +01:00
|
|
|
|
2020-08-31 16:34:29 +02:00
|
|
|
# shellcheck disable=SC2198
|
|
|
|
if [ -z "$@" ]; then
|
|
|
|
step "No command specified, exiting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-11-18 19:11:14 +01:00
|
|
|
for cmd in "$@"; do
|
|
|
|
case "$cmd" in
|
2020-08-31 16:34:29 +02:00
|
|
|
godep|docdep|release|docs)
|
2017-11-19 12:32:25 +01:00
|
|
|
eval $cmd
|
2017-11-18 19:11:14 +01:00
|
|
|
continue
|
|
|
|
;;
|
|
|
|
devsetup)
|
|
|
|
step "Installing development dependencies"
|
2018-12-01 14:09:32 +01:00
|
|
|
godep
|
2017-11-18 19:11:14 +01:00
|
|
|
docdep
|
|
|
|
step "Development dependencies installed"
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
step "Invalid command ${cmd}, exiting"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2017-11-12 16:15:12 +01:00
|
|
|
|