xenia/app/bind.sh

45 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
export PROJECTPATH=$PWD
export GOPATH="$PROJECTPATH/go"
export GO111MODULE=on
if [ -z "$1" ]; then
echo "Usage: ./bind.sh <gmitohtml tag, commit hash or local path>"
exit 1
fi
go mod init space.rocketnine.gmitohtml || true
echo "Downloading bind..."
go get golang.org/x/mobile/bind
echo "Downloading gomobile..."
go install golang.org/x/mobile/cmd/gomobile@latest
LIBPATH=""
if [[ "$1" == *\/* ]]; then
LIBPATH=$1/pkg/gmitohtml
else
echo "Downloading gmitohtml $1..."
mkdir -p $GOPATH/src/code.rocket9labs.com/tslocum
if [ ! -d "$GOPATH/src/code.rocket9labs.com/tslocum/gmitohtml" ]; then
git clone https://code.rocket9labs.com/tslocum/gmitohtml $GOPATH/src/code.rocket9labs.com/tslocum/gmitohtml
fi
cd $GOPATH/src/code.rocket9labs.com/tslocum/gmitohtml && git fetch origin && git reset --hard `printf %q "$1"` && cd $PROJECTPATH
LIBPATH=$GOPATH/src/code.rocket9labs.com/tslocum/gmitohtml/pkg/gmitohtml
fi
echo "Binding gmitohtml..."
mkdir -p libs
PATH="$PROJECTPATH/go/bin:$PATH"
if [[ ! "$1" == *\/* ]]; then
cd $LIBPATH
LIBPATH="."
fi
go get golang.org/x/mobile/bind
gomobile init
gomobile bind -target android -androidapi 21 -javapkg space.rocketnine -o $PROJECTPATH/libs/gmitohtml.aar $LIBPATH
echo "Finished."