diff --git a/tools/autobuild/android.sh b/tools/autobuild/android.sh index 938dbf3a58..9c72a4504e 100644 --- a/tools/autobuild/android.sh +++ b/tools/autobuild/android.sh @@ -11,15 +11,17 @@ if [[ $# < 1 ]]; then fi CONFIGURATION="$1" - source "$LOCAL_DIRNAME/build.sh" +source "$LOCAL_DIRNAME/ndk_helper.sh" MKSPEC="$LOCAL_DIRNAME/../mkspecs/android-g++" QMAKE_PARAMS="CONFIG+=${CONFIGURATION}" SHADOW_DIR_BASE="$LOCAL_DIRNAME/../../../omim-android" -export NDK_HOST=darwin-x86 -export NDK_ROOT=/Developer/android-ndk-r7 +# Try to read ndk root path from android/local.properties file +export NDK_ROOT=$(GetNdkRoot) || ( echo "Can't read NDK root path from android/local.properties"; exit 1 ) +export NDK_HOST=$(GetNdkHost) || ( echo "Can't get your OS type, please check tools/autobuild/ndk_helper.sh script"; exit 1 ) + NDK_ABI_TO_BUILD=(armeabi armeabi-v7a) for abi in "${NDK_ABI_TO_BUILD[@]}"; do diff --git a/tools/autobuild/ndk_helper.sh b/tools/autobuild/ndk_helper.sh new file mode 100644 index 0000000000..6e52f2e8b3 --- /dev/null +++ b/tools/autobuild/ndk_helper.sh @@ -0,0 +1,32 @@ +set -e -u + +LOCAL_DIRNAME="${PWD}/$(dirname "$0")" + +# Echoes found NDK root path or nothing if not found +# return 1 on error and 0 on success +GetNdkRoot() +{ + local FILENAME="$LOCAL_DIRNAME/../../android/local.properties" + while read line + do + if [[ "${line:0:7}" == "ndk.dir" ]]; then + echo "${line:8}" + return 0 + fi + done < $FILENAME + return 1 +} + +GetNdkHost() +{ + if [[ "${OSTYPE:0:5}" == "linux" ]]; then + echo "linux-x86" + return 0 + fi + if [[ "${OSTYPE:0:6}" == "darwin" ]]; then + echo "darwin-x86" + return 0 + fi + # TODO add Windows + return 1 +}