package builder

This commit is contained in:
Josh Baker 2016-04-03 08:35:15 -07:00
parent c0836dd1ac
commit 9060ed68d6
3 changed files with 32 additions and 3 deletions

3
.gitignore vendored
View File

@ -2,4 +2,5 @@
tile38-* tile38-*
!cmd/tile38-* !cmd/tile38-*
data*/ data*/
coverage.out coverage.out
packages/

View File

@ -13,3 +13,5 @@ install: all
uninstall: uninstall:
rm -f /usr/local/bin/tile38-server rm -f /usr/local/bin/tile38-server
rm -f /usr/local/bin/tile38-cli rm -f /usr/local/bin/tile38-cli
package:
@./build.sh package

View File

@ -70,6 +70,33 @@ export GO15VENDOREXPERIMENT=1
cd $(dirname "${BASH_SOURCE[0]}") cd $(dirname "${BASH_SOURCE[0]}")
OD="$(pwd)" OD="$(pwd)"
package(){
echo Packaging $1 Binary
bdir=tile38-v${VERSION}-$2-$3
rm -rf packages/$bdir && mkdir -p packages/$bdir
GOOS=$2 GOARCH=$3 ./build.sh
mv tile38-server packages/$bdir
mv tile38-cli packages/$bdir
cp README.md packages/$bdir
cd packages
if [ "$2" == "linux" ]; then
tar -zcf $bdir.tar.gz $bdir
else
zip -r -q $bdir.zip $bdir
fi
rm -rf $bdir
cd ..
}
if [ "$1" == "package" ]; then
rm -rf packages/
package "Windows" "windows" "amd64"
package "Mac" "darwin" "amd64"
package "Linux" "linux" "amd64"
exit
fi
# temp directory for storing isolated environment. # temp directory for storing isolated environment.
TMP="$(mktemp -d -t tile38.XXXX)" TMP="$(mktemp -d -t tile38.XXXX)"
function rmtemp { function rmtemp {
@ -91,8 +118,6 @@ if [ "$NOCOPY" != "1" ]; then
cd $WD cd $WD
fi fi
#core/gen.sh
# build and store objects into original directory. # build and store objects into original directory.
go build -ldflags "$LDFLAGS" -o "$OD/tile38-server" cmd/tile38-server/*.go go build -ldflags "$LDFLAGS" -o "$OD/tile38-server" cmd/tile38-server/*.go
go build -ldflags "$LDFLAGS" -o "$OD/tile38-cli" cmd/tile38-cli/*.go go build -ldflags "$LDFLAGS" -o "$OD/tile38-cli" cmd/tile38-cli/*.go
@ -119,3 +144,4 @@ if [ "$1" == "cover" ]; then
go test -cover $(go list ./... | grep -v /vendor/) go test -cover $(go list ./... | grep -v /vendor/)
fi fi