2015-11-13 22:38:17 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
RESET=1
|
|
|
|
|
|
|
|
MYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2016-04-13 21:59:50 +00:00
|
|
|
JNIDIR="/src/main/jniLibs"
|
2015-11-13 22:38:17 +00:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
arm)
|
2016-02-10 18:07:38 +00:00
|
|
|
export CGO_ENABLED=0
|
2016-02-10 18:21:39 +00:00
|
|
|
export GOOS=linux
|
2015-11-13 22:38:17 +00:00
|
|
|
export GOARCH=arm
|
|
|
|
export GOARM=5
|
2016-04-13 21:59:50 +00:00
|
|
|
export TARGETDIR=$MYDIR$JNIDIR/armeabi
|
2015-11-13 22:38:17 +00:00
|
|
|
;;
|
|
|
|
386)
|
2016-02-10 18:07:38 +00:00
|
|
|
export CGO_ENABLED=0
|
2016-02-10 18:21:39 +00:00
|
|
|
export GOOS=linux
|
2015-11-13 22:38:17 +00:00
|
|
|
export GOARCH=386
|
|
|
|
export GO386=387
|
2016-04-13 21:59:50 +00:00
|
|
|
export TARGETDIR=$MYDIR$JNIDIR/x86
|
2015-11-13 22:38:17 +00:00
|
|
|
;;
|
|
|
|
amd64)
|
2016-02-10 18:07:38 +00:00
|
|
|
export CGO_ENABLED=0
|
2016-02-10 18:21:39 +00:00
|
|
|
export GOOS=linux
|
2015-11-13 22:38:17 +00:00
|
|
|
export GOARCH=amd64
|
2016-04-13 21:59:50 +00:00
|
|
|
export TARGETDIR=$MYDIR$JNIDIR/x86_64
|
2015-11-13 22:38:17 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Must specify either arm or 386 or amd64"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
unset GOPATH #Set by build.go
|
|
|
|
export GOROOT=${MYDIR}/ext/golang/dist/go-${GOOS}-${GOARCH}
|
|
|
|
export PATH=${GOROOT}/bin:${PATH}
|
|
|
|
|
|
|
|
if [ $RESET -eq 1 ]; then
|
|
|
|
git submodule update --init ext/syncthing/src/github.com/syncthing/syncthing
|
|
|
|
fi
|
|
|
|
|
|
|
|
pushd ext/syncthing/src/github.com/syncthing/syncthing
|
|
|
|
|
|
|
|
_GOOS=$GOOS
|
|
|
|
unset GOOS
|
|
|
|
_GOARCH=$GOARCH
|
|
|
|
unset GOARCH
|
|
|
|
|
|
|
|
go run build.go -goos=${_GOOS} -goarch=${_GOARCH} clean
|
|
|
|
go run build.go -goos=${_GOOS} -goarch=${_GOARCH} -no-upgrade build
|
|
|
|
|
|
|
|
export GOOS=$_GOOS
|
|
|
|
export GOARCH=$_GOARCH
|
|
|
|
|
|
|
|
mkdir -p ${TARGETDIR}
|
|
|
|
mv syncthing ${TARGETDIR}/libsyncthing.so
|
|
|
|
chmod 644 ${TARGETDIR}/libsyncthing.so
|
|
|
|
|
|
|
|
if [[ RESET -eq 1 && -e ./build.go ]]; then
|
|
|
|
git clean -f
|
|
|
|
fi
|
|
|
|
|
|
|
|
popd
|
|
|
|
|
|
|
|
if [ $RESET -eq 1 ]; then
|
|
|
|
git submodule update --init ext/syncthing/src/github.com/syncthing/syncthing
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Build Complete"
|
|
|
|
|