#!/bin/sh


LIST_ARCHITECTURES='armeabi-v7a arm64-v8a x86 x86_64'

LIBUSB_FOLDER=$1
SFML_FOLDER=$2
STL_CHOSEN=$3
RELEASE_TYPE=$4

CONFIGURE_SINGLE_ARCH_SFML_COMMAND=docker-scripts/docker_config_android_sfml_single_arch
BUILD_SINGLE_ARCH_SFML_COMMAND=docker-scripts/docker_build_android_sfml_single_arch

(cd ${LIBUSB_FOLDER}/android/jni ; ndk-build APP_PLATFORM=${ANDROID_SDK_VERSION} -j ; mkdir -p ${ANDROID_NDK_HOME}/sources/third_party/libusb/include ; cp -r ../libs/ ${ANDROID_NDK_HOME}/sources/third_party/libusb ; cp -r ../../libusb ${ANDROID_NDK_HOME}/sources/third_party/libusb/include)

for target_arch in ${LIST_ARCHITECTURES};
do
	${CONFIGURE_SINGLE_ARCH_SFML_COMMAND} ${SFML_FOLDER} ${target_arch} ${STL_CHOSEN} ${RELEASE_TYPE} &
done

wait $(jobs -p)
echo "All libraries configured..."

for target_arch in ${LIST_ARCHITECTURES};
do
	${BUILD_SINGLE_ARCH_SFML_COMMAND} ${SFML_FOLDER} ${target_arch}
done
