From a105ad139172919b701cf7b8ebab959f91b4728a Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 12 May 2014 20:00:57 -0300 Subject: [PATCH] Easy godep/go vet setup. --- build.sh | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/build.sh b/build.sh index da8d504a8..127d06ae9 100755 --- a/build.sh +++ b/build.sh @@ -10,25 +10,28 @@ host=$(hostname) host=${host%%.*} ldflags="-w -X main.Version $version -X main.BuildStamp $date -X main.BuildUser $user -X main.BuildHost $host" +check() { + if ! command -v godep >/dev/null ; then + echo "Error: no godep. Try \"$0 setup\"." + exit 1 + fi +} + build() { + check + go vet ./... || exit 1 - if command -v godep >/dev/null ; then - godep=godep - else - echo "Warning: no godep, using \"go get\" instead." - echo "Try \"go get github.com/tools/godep\"." - go get -d ./cmd/syncthing - godep= - fi - ${godep} go build $* -ldflags "$ldflags" ./cmd/syncthing + godep go build $* -ldflags "$ldflags" ./cmd/syncthing } assets() { + check godep go run cmd/assets/assets.go gui > auto/gui.files.go } test() { + check godep go test -cpu=1,2,4 ./... } @@ -63,9 +66,17 @@ zipDist() { } deps() { + check godep save ./cmd/syncthing ./cmd/assets ./discover/cmd/discosrv } +setup() { + echo Installing godep... + go get -u github.com/tools/godep + echo Installing go vet... + go get -u code.google.com/p/go.tools/cmd/vet +} + case "$1" in "") shift @@ -149,6 +160,10 @@ case "$1" in assets ;; + setup) + setup + ;; + *) echo "Unknown build parameter $1" ;;