2020-09-02 21:34:52 +02:00
#!/usr/bin/env 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 } "
}
2020-09-02 21:34:52 +02:00
godep( ) {
step "install build dependencies (versions pinned in build/go.mod and build/tools.go)"
2017-11-18 19:11:14 +01:00
2020-09-02 21:34:52 +02:00
if ! type go >/dev/null; then
step "go binary not installed or not in \$PATH" 1>& 2
exit 1
fi
2017-11-12 16:15:12 +01:00
2020-09-02 21:34:52 +02:00
if [ -z " $GOPATH " ] ; then
step "Your GOPATH is not configured correctly" 1>& 2
exit 1
fi
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
2019-10-26 13:55:03 +02:00
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
2020-09-02 21:34:52 +02:00
source <( go env)
export GOOS = " $GOHOSTOS "
export GOARCH = " $GOHOSTARCH "
# TODO GOARM=$GOHOSTARM?
2021-01-24 23:25:24 +01:00
cat tools.go | grep _ | awk -F'"' '{print $2}' | tee | xargs -tI '{}' go install '{}'
2019-09-03 14:45:18 +02:00
set +x
2019-10-26 13:55:03 +02:00
popd
2021-01-24 23:31:45 +01:00
if ! type stringer || ! type protoc-gen-go || ! type protoc-gen-go-grpc || ! 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