Adding mingw64 (msys2) to build script

This commit is contained in:
Nicolas Dextraze 2018-03-17 11:28:23 -07:00
parent 996431a4d9
commit da907dbbd8

View File

@ -1,30 +1,92 @@
#!/bin/bash
case "$(uname -s)" in
Linux*) platform=linux;;
Darwin*) platform=unsupported;;
CYGWIN*) platform=unsupported;;
MINGW*) platform=mingw;;
*) platform=unsupported
esac
if [ "$platform" == "unsupported" ]; then
echo "Error: Unsupported platform $(uname -s)"
exit
fi
# check for dependencies
if [ ! "$(which pacman)" == "" ]; then
pacman -S --needed --noconfirm msys/autoconf msys/automake-wrapper msys/libtool msys/pkg-config msys/git
fi
git=`which git`
if [ "$git" == "" ]; then
echo "Error: Git not found in PATH"
exit -1
fi
go=`which go`
if [ "$go" == "" ]; then
echo "Error: Go not found in PATH"
exit -1
fi
# clean # clean
rm -rf bin rm -rf bin
# create folders # create folders
mkdir .go if [ ! -e .deps ]; then
mkdir .deps mkdir .deps
fi
# get and build libzmq # get and build libzmq
cd .deps cd .deps
if [ ! -e libzmq ]; then
git clone https://github.com/zeromq/libzmq git clone https://github.com/zeromq/libzmq
fi
cd libzmq cd libzmq
git checkout v4.2.3 git checkout v4.2.3
./autogen.sh && ./configure && make if [ ! -e Makefile ]; then
./autogen.sh && ./configure --enable-static
fi
if [ "$platform" == "mingw" ]; then
sed -i 's/MAKE=make/MAKE=mingw32-make/' Makefile
mingw32-make
else
make
fi
cd ../.. cd ../..
# get and build go zmq4 # get and build go zmq4
GOPATH=`pwd`/.go GOPATH=`pwd`/.deps go get
go get
# use built libzmq # use built libzmq
if [ "$platform" == "linux" ]; then
ESC_PWD=`pwd | sed 's/\//\\\\\//g'` ESC_PWD=`pwd | sed 's/\//\\\\\//g'`
cflags="\#cgo \!windows CFLAGS\: \-I${ESC_PWD}\/\.deps\/libzmq\/include" cflags="\#cgo \!windows CFLAGS\: \-I${ESC_PWD}\/\.deps\/libzmq\/include"
ldflags="\#cgo \!windows LDFLAGS\: ${ESC_PWD}\/\.deps\/libzmq\/src\/\.libs\/libzmq\.a \-lstdc\+\+ \-lm" ldflags="\#cgo \!windows LDFLAGS\: ${ESC_PWD}\/\.deps\/libzmq\/src\/\.libs\/libzmq\.a \-lstdc\+\+ \-lm"
sed -i "4s/.*/${cflags}/" .go/src/github.com/pebbe/zmq4/zmq4.go sed -i "4s/.*/${cflags}/" .deps/src/github.com/pebbe/zmq4/zmq4.go
sed -i "5s/.*/${ldflags}/" .go/src/github.com/pebbe/zmq4/zmq4.go sed -i "5s/.*/${ldflags}/" .deps/src/github.com/pebbe/zmq4/zmq4.go
fi
if [ "$platform" == "mingw" ]; then
ESC_PWD=`pwd | sed 's/\/\(.\)/\1:/' | sed 's/\//\\\\\//g'`
cflags="\#cgo windows CFLAGS\: \-I${ESC_PWD}\/\.deps\/libzmq\/include \-DZMQ_STATIC"
ldflags="\#cgo windows LDFLAGS\: ${ESC_PWD}\/\.deps\/libzmq\/src\/\.libs\/libzmq\.a -lstdc++ -lwsock32 -lws2_32 -lIphlpapi"
sed -i "5s/.*/${cflags}/" .deps/src/github.com/pebbe/zmq4/zmq4.go
sed -i "6s/.*/${ldflags}/" .deps/src/github.com/pebbe/zmq4/zmq4.go
fi
# build goes # build goes
go build -a -ldflags '-s' -o bin/goes goes.go OUTPUT=bin/goes
if [ "$platform" == "mingw" ]; then
OUTPUT=bin/goes.exe
fi
GOPATH=`pwd`/.deps go build -a -ldflags '-s' -o ${OUTPUT} goes.go
# copy libstdc++ deps mingw
if [ "$platform" == "mingw" ]; then
cp /mingw64/bin/libstd*.dll bin
cp /mingw64/bin/libgcc*.dll bin
cp /mingw64/bin/libwin*.dll bin
fi
# copy licenses # copy licenses
cp .deps/libzmq/COPYING bin/libzmq.COPYING cp .deps/libzmq/COPYING bin/libzmq.COPYING
@ -32,4 +94,3 @@ cp .deps/libzmq/COPYING.LESSER bin/libzmq.COPYING.LESSER
cp LICENSE bin/LICENSE cp LICENSE bin/LICENSE
tar -czvf goes.tar.gz bin/ tar -czvf goes.tar.gz bin/