storj/lib/uplink-gomobile/build.sh

48 lines
1.0 KiB
Bash
Raw Normal View History

#!/bin/bash
# This script will build libuplink-android.aar library from scratch
# Required:
# * ANDROID_HOME set with NDK available
# * go
if [ -z "$ANDROID_HOME" ]
then
echo "\$ANDROID_HOME is not set"
exit 1
fi
2019-10-04 09:56:42 +01:00
# setup tmpdir for testfiles and cleanup
TMP=$(mktemp -d -t tmp.XXXXXXXXXX)
cleanup(){
rm -rf "$TMP"
}
trap cleanup EXIT
2019-10-04 09:56:42 +01:00
OUTPUT=$PWD
# go knows where our gopath is
2019-10-04 09:56:42 +01:00
export GOPATH=$TMP
2019-10-04 09:56:42 +01:00
mkdir "$GOPATH/src"
2019-10-04 09:56:42 +01:00
# symlink doesn't look to be working with gomobile
# ln -s "$PWD/../storj" "$GOPATH/src/storj.io/storj"
rsync -am --stats --exclude=".*" "$PWD/../storj" "$GOPATH/src/storj.io/"
2019-10-04 09:56:42 +01:00
cd "$GOPATH/src/storj.io/storj"
2019-10-04 09:56:42 +01:00
go mod vendor
2019-10-04 09:56:42 +01:00
cp -r $GOPATH/src/storj.io/storj/vendor/* "$GOPATH/src"
2019-10-04 09:56:42 +01:00
# set go modules to default behavior
export GO111MODULE=off
go get golang.org/x/mobile/cmd/gomobile
2019-10-04 09:56:42 +01:00
$GOPATH/bin/gomobile init
$GOPATH/bin/gomobile bind -v -target android -o "$OUTPUT/libuplink-android.aar" -javapkg io.storj.libuplink storj.io/storj/lib/uplink-gomobile
2019-10-04 09:56:42 +01:00
# cleanup pkg/mod directory
go clean -modcache