From 2f85b4524c9c7c6662a784be77d235c05392e7d4 Mon Sep 17 00:00:00 2001 From: Javernaut Date: Sun, 22 Mar 2020 11:42:55 +0200 Subject: [PATCH] Checking for ANDROID_SDK_HOME and ANDROID_NDK_HOME variables before script execution --- ffmpeg-android-maker.sh | 3 +++ scripts/check-host-machine.sh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100755 scripts/check-host-machine.sh diff --git a/ffmpeg-android-maker.sh b/ffmpeg-android-maker.sh index 19b2780..8cba281 100755 --- a/ffmpeg-android-maker.sh +++ b/ffmpeg-android-maker.sh @@ -18,6 +18,9 @@ export SCRIPTS_DIR=${BASE_DIR}/scripts # All FFmpeg's libraries and headers are copied there export OUTPUT_DIR=${BASE_DIR}/output +# Check the host machine for proper setup and fail fast otherwise +${SCRIPTS_DIR}/check-host-machine.sh || exit 1 + # Directory to use as a place to build/install FFmpeg and its dependencies BUILD_DIR=${BASE_DIR}/build # Separate directory to build FFmpeg to diff --git a/scripts/check-host-machine.sh b/scripts/check-host-machine.sh new file mode 100755 index 0000000..faf3280 --- /dev/null +++ b/scripts/check-host-machine.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +function checkVariablePresence() { + VARIABLE_NAME=$1 + if [[ -z "${!VARIABLE_NAME}" ]]; then + echo "The ${VARIABLE_NAME} environment variable isn't defined" + echo $2 + exit 1 + fi +} + +checkVariablePresence "ANDROID_SDK_HOME" \ + "The variable should be set to the actual Android SDK path" || exit 1 + +checkVariablePresence "ANDROID_NDK_HOME" \ + "The variable should be set to the actual Android NDK path" || exit 1