2019-05-24 09:13:01 +01:00
|
|
|
#!/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-05-24 09:13:01 +01:00
|
|
|
|
2019-10-04 09:56:42 +01:00
|
|
|
OUTPUT=$PWD
|
2019-05-24 09:13:01 +01:00
|
|
|
|
|
|
|
# go knows where our gopath is
|
2019-10-04 09:56:42 +01:00
|
|
|
export GOPATH=$TMP
|
2019-05-24 09:13:01 +01:00
|
|
|
|
2019-10-04 09:56:42 +01:00
|
|
|
mkdir "$GOPATH/src"
|
2019-05-24 09:13:01 +01:00
|
|
|
|
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-05-24 09:13:01 +01:00
|
|
|
|
2019-10-04 09:56:42 +01:00
|
|
|
cd "$GOPATH/src/storj.io/storj"
|
2019-05-24 09:13:01 +01:00
|
|
|
|
2019-10-04 09:56:42 +01:00
|
|
|
go mod vendor
|
2019-05-24 09:13:01 +01:00
|
|
|
|
2019-10-04 09:56:42 +01:00
|
|
|
cp -r $GOPATH/src/storj.io/storj/vendor/* "$GOPATH/src"
|
2019-05-24 09:13:01 +01:00
|
|
|
|
2019-10-04 09:56:42 +01:00
|
|
|
# set go modules to default behavior
|
|
|
|
export GO111MODULE=off
|
2019-05-24 09:13:01 +01:00
|
|
|
|
|
|
|
go get golang.org/x/mobile/cmd/gomobile
|
|
|
|
|
2019-10-04 09:56:42 +01:00
|
|
|
$GOPATH/bin/gomobile init
|
|
|
|
|
2019-10-06 23:34:12 +01:00
|
|
|
$GOPATH/bin/gomobile bind -v -target android -o "$OUTPUT/libuplink-android.aar" -javapkg io.storj.libuplink storj.io/storj/lib/uplink-gomobile
|
2019-05-24 09:13:01 +01:00
|
|
|
|
2019-10-04 09:56:42 +01:00
|
|
|
# cleanup pkg/mod directory
|
|
|
|
go clean -modcache
|