syncthing/build.sh

52 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2013-12-21 23:16:49 +00:00
#!/bin/bash
export COPYFILE_DISABLE=true
2013-12-21 23:16:49 +00:00
version=$(git describe --always)
2014-01-06 05:11:19 +00:00
buildDir=dist
2013-12-21 23:16:49 +00:00
if [[ $fast != yes ]] ; then
2014-01-09 22:00:23 +00:00
go get -d
2014-01-06 14:50:15 +00:00
go test ./...
fi
if [[ -z $1 ]] ; then
go build -ldflags "-X main.Version $version"
elif [[ $1 == "embed" ]] ; then
embedder auto gui > auto/gui.files.go \
2014-01-23 12:13:15 +00:00
&& go build -ldflags "-X main.Version $version"
elif [[ $1 == "tar" ]] ; then
go build -ldflags "-X main.Version $version" \
&& mkdir syncthing-dist \
&& cp syncthing README.md LICENSE syncthing-dist \
&& tar zcvf syncthing-dist.tar.gz syncthing-dist \
&& rm -rf syncthing-dist
elif [[ $1 == "all" ]] ; then
2014-01-06 05:11:19 +00:00
rm -rf "$buildDir"
mkdir -p "$buildDir" || exit 1
2013-12-22 22:13:51 +00:00
2014-02-01 09:10:07 +00:00
export GOARM=7
for os in darwin-amd64 linux-386 linux-amd64 linux-arm freebsd-386 freebsd-amd64 windows-386 windows-amd64 ; do
echo "$os"
export name="syncthing-$os"
export GOOS=${os%-*}
export GOARCH=${os#*-}
go build -ldflags "-X main.Version $version"
mkdir -p "$name"
cp README.md LICENSE "$name"
case $GOOS in
windows)
cp syncthing.exe "$buildDir/$name.exe"
mv syncthing.exe "$name"
zip -qr "$buildDir/$name.zip" "$name"
;;
*)
cp syncthing "$buildDir/$name"
mv syncthing "$name"
tar zcf "$buildDir/$name.tar.gz" "$name"
;;
esac
rm -r "$name"
2013-12-21 23:16:49 +00:00
done
2014-01-05 22:54:57 +00:00
fi