From 55f92a329c3cc26bcd378d08be1bd00d374a62cc Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Sun, 7 Jan 2024 09:45:37 +0100 Subject: [PATCH] [build,android] simplify SDK cmake check --- scripts/android-build-cjson.sh | 1 - scripts/android-build-common.sh | 177 ++++++++++++++---------------- scripts/android-build-ffmpeg.sh | 1 - scripts/android-build-openh264.sh | 1 - scripts/android-build-openssl.sh | 1 - 5 files changed, 85 insertions(+), 96 deletions(-) diff --git a/scripts/android-build-cjson.sh b/scripts/android-build-cjson.sh index 5610096f7..5b5e9dcd5 100755 --- a/scripts/android-build-cjson.sh +++ b/scripts/android-build-cjson.sh @@ -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 diff --git a/scripts/android-build-common.sh b/scripts/android-build-common.sh index 2e58331a9..416a511ff 100644 --- a/scripts/android-build-common.sh +++ b/scripts/android-build-common.sh @@ -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,79 +95,6 @@ function common_run { fi } -function common_parse_arguments { - while [[ $# > 0 ]] - do - key="$1" - case $key in - --conf) - source "$2" || exit 1 - shift - ;; - - --target) - NDK_TARGET="$2" - shift - ;; - - --ndk) - ANDROID_NDK="$2" - shift - ;; - - --sdk) - ANDROID_SDK="$2" - CMAKE_PROGRAM=$(find $ANDROID_SDK/cmake -name cmake $FIND_ARGS) - shift - ;; - - --arch) - BUILD_ARCH="$2" - shift - ;; - - --dst) - BUILD_DST="$2" - shift - ;; - - --src) - BUILD_SRC="$2" - shift - ;; - - --url) - SCM_URL="$2" - shift - ;; - - --tag) - SCM_TAG="$2" - shift - ;; - - --hash) - SCM_HASH="$2" - shift - ;; - - --clean) - CLEAN_BUILD_DIR=1 - shift - ;; - - --help) - common_help - shift - ;; - - *) # Unknown - ;; - esac - shift - done -} - function common_check_requirements { if [[ ! -d $ANDROID_NDK ]]; then @@ -196,13 +127,13 @@ function common_check_requirements { if [[ -z $SCM_TAG ]]; then - echo "SCM TAG / BRANCH not defined! Define SCM_TAG" + 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" + echo "SCM_HASH not defined! Define SCM_HASH" exit 1 fi @@ -212,19 +143,7 @@ function common_check_requirements { 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 + 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!" @@ -232,7 +151,7 @@ function common_check_requirements { fi fi - for CMD in make git $CMAKE_PROGRAM $NDK_BUILD + 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." @@ -250,6 +169,80 @@ function common_check_requirements { fi } +function common_parse_arguments { + while [[ $# > 0 ]] + do + key="$1" + case $key in + --conf) + source "$2" || exit 1 + shift + ;; + + --target) + NDK_TARGET="$2" + shift + ;; + + --ndk) + ANDROID_NDK="$2" + shift + ;; + + --sdk) + ANDROID_SDK="$2" + shift + ;; + + --arch) + BUILD_ARCH="$2" + shift + ;; + + --dst) + BUILD_DST="$2" + shift + ;; + + --src) + BUILD_SRC="$2" + shift + ;; + + --url) + SCM_URL="$2" + shift + ;; + + --tag) + SCM_TAG="$2" + shift + ;; + + --hash) + SCM_HASH="$2" + shift + ;; + + --clean) + CLEAN_BUILD_DIR=1 + shift + ;; + + --help) + common_help + shift + ;; + + *) # Unknown + ;; + esac + shift + done + + common_check_requirements +} + function common_update { if [ $# -ne 4 ]; then diff --git a/scripts/android-build-ffmpeg.sh b/scripts/android-build-ffmpeg.sh index 2a8f9486a..96094c746 100755 --- a/scripts/android-build-ffmpeg.sh +++ b/scripts/android-build-ffmpeg.sh @@ -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` diff --git a/scripts/android-build-openh264.sh b/scripts/android-build-openh264.sh index 44d39f660..ec0210801 100755 --- a/scripts/android-build-openh264.sh +++ b/scripts/android-build-openh264.sh @@ -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 diff --git a/scripts/android-build-openssl.sh b/scripts/android-build-openssl.sh index 48b7dcd36..8139e8ab5 100755 --- a/scripts/android-build-openssl.sh +++ b/scripts/android-build-openssl.sh @@ -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