#!/bin/bash

echo '### p4a started'

# sdk-dir and nkd-dir from command line (fdroid mode)

sdkdir="${HOME}/.cache/sdk-for-p4a"
ndkdir="${HOME}/.cache/sdk-for-p4a/ndk-bundle"
if [ $1 ]
then
  echo "set sdk to: $1"
  sdkdir="$1"
fi
if [ $2 ]
then
  echo "set ndk to: $2"
  ndkdir="$2"
fi

echo '### run toolchain'

version=`./version.py`
tmpdir=${HOME}/.cache/tmp-for-p4a/pysolfc/src

python3 -m pythonforandroid.toolchain apk \
  --sdk-dir ${sdkdir} \
  --ndk-dir ${ndkdir} \
  --android-api 19 \
  --ndk-version r12b \
  --arch armeabi-v7a \
  --dist-name pysolfc \
  --name PySolFC \
  --bootstrap=sdl2 \
  --requirements kivy,hostpython2,random2 \
  --release \
  --minsdk 14 \
  --private ${tmpdir} \
  --package org.lufebe16.pysolfc \
  --version ${version} \
  --orientation sensor \
  --color=always \
  --icon ${tmpdir}/data/images/misc/pysol01.png \
  --presplash ${tmpdir}/data/images/misc/pysol06.png \
  --copy-libs

# python3 -m pythonforandroid.toolchain apk
# ...
# --release          #1
# --sign             #2
# ...
#
# ad 1,2:
# ohne:    -> debug version
# 1:       -> release unsigned
# 1 und 2: -> release version.

echo '### p4a finished'
