#!/bin/bash
set -eux
# This script mimics the instructions laid out in the p4a documentation:
# https://python-for-android.readthedocs.io/en/latest/quickstart/

. mkp4a.common

urlbase=https://dl.google.com/android/repository/

if [[ -d $ndkdir ]]; then
  echo "Skipping NDK installation: NDK directory already exists."
else
  mkdir -p $ndkdir
  ndk_zip=android-ndk-${ndkver}-linux-x86_64.zip
  [ -a $ndk_zip ] || wget $urlbase/$ndk_zip
  unzip -d $(dirname $ndkdir) $ndk_zip
fi

if [[ -d $sdkdir  ]]; then
  echo "Skipping SDK installation: SDK directory already exists."
else
  mkdir -p $sdkdir
  tools_zip=sdk-tools-linux-4333796.zip
  [ -a $tools_zip ] || wget $urlbase/$tools_zip
  unzip -d $sdkdir $tools_zip

  $sdkdir/tools/bin/sdkmanager 'platforms;android-27'
  $sdkdir/tools/bin/sdkmanager 'build-tools;29.0.1'
fi


