[build,android] simplify SDK cmake check

This commit is contained in:
Armin Novak 2024-01-07 09:45:37 +01:00 committed by Martin Fleisz
parent 47017af3e4
commit 55f92a329c
5 changed files with 85 additions and 96 deletions

View File

@ -8,7 +8,6 @@ source $(dirname "${BASH_SOURCE[0]}")/android-build-common.sh
# Run the main program.
common_parse_arguments $@
common_check_requirements
common_update $SCM_URL $SCM_TAG $BUILD_SRC $SCM_HASH
# Prepare the environment

View File

@ -24,7 +24,7 @@ if [ -z $NDK_TARGET ]; then
fi
if [ -z $CMAKE_PROGRAM ]; then
CMAKE_PROGRAM=$(find $ANDROID_SDK/cmake -name cmake $FIND_ARGS)
CMAKE_PROGRAM="cmake-missing"
fi
if [ -z $CCACHE ]; then
@ -32,11 +32,11 @@ if [ -z $CCACHE ]; then
fi
if [ -z $ANDROID_NDK ]; then
ANDROID_NDK="missing"
ANDROID_NDK="ndk-missing"
fi
if [ -z $ANDROID_SDK ]; then
ANDROID_SDK="missing"
ANDROID_SDK="sdk-missing"
fi
if [ -z $BUILD_DST ]; then
@ -55,6 +55,10 @@ if [ -z $SCM_TAG ]; then
SCM_TAG=master
fi
if [ -z $SCM_HASH ]; then
SCM_HASH="missing"
fi
CLEAN_BUILD_DIR=0
function common_help {
@ -91,6 +95,80 @@ function common_run {
fi
}
function common_check_requirements {
if [[ ! -d $ANDROID_NDK ]];
then
echo "export ANDROID_NDK to point to your NDK location."
exit 1
fi
if [[ ! -d $ANDROID_SDK ]];
then
echo "export ANDROID_SDK to point to your SDK location."
exit 1
fi
if [[ -z $BUILD_DST ]];
then
echo "Destination directory not valid"
exit 1
fi
if [[ -z $BUILD_SRC ]];
then
echo "Source directory not valid"
exit 1
fi
if [[ -z $SCM_URL ]];
then
echo "Source URL not defined! Define SCM_URL"
exit 1
fi
if [[ -z $SCM_TAG ]];
then
echo "SCM_TAG / BRANCH not defined! Define SCM_TAG"
exit 1
fi
if [[ -z $SCM_HASH ]];
then
echo "SCM_HASH not defined! Define SCM_HASH"
exit 1
fi
if [[ -z $NDK_TARGET ]];
then
echo "Android platform NDK_TARGET not defined"
exit 1
fi
if [ -z $CMAKE_PROGRAM ] || [ "$CMAKE_PROGRAM" == "cmake-missing" ]; then
CMAKE_PROGRAM=$(find $ANDROID_SDK/cmake -name cmake $FIND_ARGS)
if [ -z $CMAKE_PROGRAM ]; then
echo "CMake not found in $ANDROID_SDK, install CMake from the android SDK!"
exit 1
fi
fi
for CMD in make git $CMAKE_PROGRAM
do
if ! type $CMD >/dev/null; then
echo "Command $CMD not found. Install and add it to the PATH."
exit 1
fi
done
if [ "${BUILD_SRC:0:1}" != "/" ];
then
BUILD_SRC=$(pwd)/$BUILD_SRC
fi
if [ "${BUILD_DST:0:1}" != "/" ];
then
BUILD_DST=$(pwd)/$BUILD_DST
fi
}
function common_parse_arguments {
while [[ $# > 0 ]]
do
@ -113,7 +191,6 @@ function common_parse_arguments {
--sdk)
ANDROID_SDK="$2"
CMAKE_PROGRAM=$(find $ANDROID_SDK/cmake -name cmake $FIND_ARGS)
shift
;;
@ -162,92 +239,8 @@ function common_parse_arguments {
esac
shift
done
}
function common_check_requirements {
if [[ ! -d $ANDROID_NDK ]];
then
echo "export ANDROID_NDK to point to your NDK location."
exit 1
fi
if [[ ! -d $ANDROID_SDK ]];
then
echo "export ANDROID_SDK to point to your SDK location."
exit 1
fi
if [[ -z $BUILD_DST ]];
then
echo "Destination directory not valid"
exit 1
fi
if [[ -z $BUILD_SRC ]];
then
echo "Source directory not valid"
exit 1
fi
if [[ -z $SCM_URL ]];
then
echo "Source URL not defined! Define SCM_URL"
exit 1
fi
if [[ -z $SCM_TAG ]];
then
echo "SCM TAG / BRANCH not defined! Define SCM_TAG"
exit 1
fi
if [[ -z $SCM_HASH ]];
then
echo "SCM HASH not defined! Define SCM_HASH"
exit 1
fi
if [[ -z $NDK_TARGET ]];
then
echo "Android platform NDK_TARGET not defined"
exit 1
fi
if [ -x $ANDROID_NDK/ndk-build ]; then
NDK_BUILD=$ANDROID_NDK/ndk-build
else
echo "ndk-build not found in NDK directory $ANDROID_NDK"
echo "assuming ndk-build is in path..."
NDK_BUILD=$(which ndk-build)
if [ -z $NDK_BUILD ]; then
echo "ndk-build not found in $ANDROID_NDK and not in PATH"
exit 1
fi
fi
if [ -z $CMAKE_PROGRAM ]; then
CMAKE_PROGRAM=$(find $ANDROID_SDK/cmake -name cmake $FIND_ARGS)
if [ -z $CMAKE_PROGRAM ]; then
echo "CMake not found in $ANDROID_SDK, install CMake from the android SDK!"
exit 1
fi
fi
for CMD in make git $CMAKE_PROGRAM $NDK_BUILD
do
if ! type $CMD >/dev/null; then
echo "Command $CMD not found. Install and add it to the PATH."
exit 1
fi
done
if [ "${BUILD_SRC:0:1}" != "/" ];
then
BUILD_SRC=$(pwd)/$BUILD_SRC
fi
if [ "${BUILD_DST:0:1}" != "/" ];
then
BUILD_DST=$(pwd)/$BUILD_DST
fi
common_check_requirements
}
function common_update {

View File

@ -136,7 +136,6 @@ function build {
# Run the main program.
common_parse_arguments $@
common_check_requirements
common_update $SCM_URL $SCM_TAG $BUILD_SRC $SCM_HASH
HOST_PKG_CONFIG_PATH=`command -v pkg-config`

View File

@ -26,7 +26,6 @@ function build {
# Run the main program.
common_parse_arguments $@
common_check_requirements
common_update $SCM_URL $SCM_TAG $BUILD_SRC $SCM_HASH

View File

@ -43,7 +43,6 @@ function build {
# Run the main program.
common_parse_arguments $@
common_check_requirements
common_update $SCM_URL $SCM_TAG $BUILD_SRC $SCM_HASH
ORG_PATH=$PATH