1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 11:21:29 +00:00
syncthing-android/build-syncthing.sh

79 lines
2.3 KiB
Bash
Raw Normal View History

#!/bin/bash -e
# Build the syncthing library
ORIG=$(pwd)
mkdir -p bin
# Load submodules
if [ ! -f "ext/syncthing/src/github.com/syncthing/syncthing/.git" ]; then
2014-11-17 11:46:27 +00:00
git submodule update --init --recursive
fi
2014-11-17 11:46:27 +00:00
# Check for GOLANG installation
2015-01-14 10:57:34 +00:00
if [ -z $GOROOT ] || [[ $(go version) != go\ version\ go1.4* ]] ; then
2014-11-17 11:46:27 +00:00
mkdir -p "build"
tmpgo='build/go'
if [ ! -f "$tmpgo/bin/go" ]; then
2015-01-14 10:57:34 +00:00
# Download GOLANG v1.4
2015-01-15 17:58:04 +00:00
wget -O go.src.tar.gz http://golang.org/dl/go1.4.src.tar.gz
2014-11-17 11:46:27 +00:00
sha1=$(sha1sum go.src.tar.gz)
2015-01-14 10:57:34 +00:00
if [ "$sha1" != "6a7d9bd90550ae1e164d7803b3e945dc8309252b go.src.tar.gz" ]; then
2014-11-17 11:46:27 +00:00
echo "go.src.tar.gz SHA1 checksum does not match!"
exit 1
fi
mkdir -p $tmpgo
tar -xzf go.src.tar.gz --strip=1 -C $tmpgo
rm go.src.tar.gz
# Build GO for host
pushd $tmpgo/src
./make.bash --no-clean
popd
fi
# Add GO to the environment
export GOROOT="$(pwd)/$tmpgo"
fi
# Add GO compiler to PATH
2015-01-15 17:52:59 +00:00
export PATH=$GOROOT/bin:$PATH
# Disable CGO (no dynamic linking)
export CGO_ENABLED=0
# Check whether GOLANG is compiled with cross-compilation for 386
if [ ! -f $GOROOT/bin/linux_386/go ]; then
2014-11-17 11:46:27 +00:00
pushd $GOROOT/src
# Build GO for cross-compilation
2015-01-15 17:52:59 +00:00
GOOS=linux GOARCH=386 GO386=387 ./make.bash --no-clean
2014-11-17 11:46:27 +00:00
popd
fi
# Check whether GOLANG is compiled with cross-compilation for arm
if [ ! -f $GOROOT/bin/linux_arm/go ]; then
2014-11-17 11:46:27 +00:00
pushd $GOROOT/src
# Build GO for cross-compilation
GOOS=linux GOARCH=arm ./make.bash --no-clean
popd
fi
# Setup GOPATH
cd "ext/syncthing/"
export GOPATH="$(pwd)"
# Install godep
$GOROOT/bin/go get github.com/tools/godep
2014-08-21 19:35:44 +00:00
export PATH="$(pwd)/bin":$PATH
2014-08-21 19:35:44 +00:00
# Setup syncthing and clean
export ENVIRONMENT=android
2014-08-21 19:35:44 +00:00
cd src/github.com/syncthing/syncthing
$GOROOT/bin/go run build.go clean
# X86
$GOROOT/bin/go run build.go -goos linux -goarch 386 -no-upgrade build
mv syncthing $ORIG/bin/syncthing-x86
$GOROOT/bin/go run build.go clean
2015-01-14 10:51:07 +00:00
# ARM
$GOROOT/bin/go run build.go -goos linux -goarch arm -no-upgrade build
mv syncthing $ORIG/bin/syncthing-armeabi
$GOROOT/bin/go run build.go clean