Skip to content
This repository has been archived by the owner on Jun 14, 2018. It is now read-only.

Commit

Permalink
Fix old build process for newer Go
Browse files Browse the repository at this point in the history
  • Loading branch information
calmh committed Sep 16, 2016
1 parent a1d691e commit 651f85b
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions build.sh
@@ -1,10 +1,11 @@
#!/bin/bash
set -euo pipefail

pkg=github.com/calmh/mole
buildstamp=$(date +%s)
buildver=$(git describe --always --dirty)
builduser="$(whoami)@$(hostname)"
ldflags="-w -X main.buildStamp '$buildstamp' -X main.buildVersion '$buildver' -X main.buildUser '$builduser'"
ldflags="-w -X main.buildStamp=$buildstamp -X main.buildVersion=$buildver -X main.buildUser=$builduser"

export GOBIN=$(pwd)/bin

Expand All @@ -16,7 +17,8 @@ buildClient() {
export GOOS=${arch%-*}
export GOARCH=${arch#*-}
rm -rf bin
godep go install -ldflags "$ldflags" "$pkg/cmd/mole"
mkdir bin
godep go build -ldflags "$ldflags" -o bin/mole "$pkg/cmd/mole"
tar zcf "mole-$arch.tar.gz" bin

[ -f bin/mole ] && mv bin/mole "auto/mole-$arch"
Expand All @@ -30,40 +32,23 @@ buildClient() {
export GOOS=${arch%-*}
export GOARCH=${arch#*-}
rm -rf bin
godep go install -ldflags "$ldflags" "$pkg/cmd/mole"
mkdir bin
godep go build -ldflags "$ldflags" -o bin/mole.exe "$pkg/cmd/mole"
zip -qr "mole-$arch.zip" bin
done
rm -rf bin
}

buildServer() {
rm -rf srv bin
mkdir srv
source /usr/local/golang-crosscompile/crosscompile.bash
for arch in linux-386 linux-amd64 darwin-amd64 ; do
echo "$arch"
"go-$arch" install -ldflags "$ldflags" "$pkg/cmd/molesrv"
[ -f bin/molesrv ] && mv bin/molesrv "srv/molesrv-$arch"
[ -f bin/*/molesrv ] && mv bin/*/molesrv "srv/molesrv-$arch"
done
rm -rf bin
tar zcf molesrv-all.tar.gz srv
}

case $1 in
case ${1:-default} in
all)
rm -fr "$GOPATH"/pkg
godep go test ./...
echo
echo Client
echo
buildClient
echo
echo Server
echo
buildServer
;;
*)
default)
godep go install -ldflags "$ldflags" "$pkg/cmd/..."
;;
esac

0 comments on commit 651f85b

Please sign in to comment.