-
Notifications
You must be signed in to change notification settings - Fork 89
/
build.android
executable file
·72 lines (64 loc) · 2.41 KB
/
build.android
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
set -e -x -u
# Get directory this script is in
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
OSNAME=android
BUILD_CONFIG=Release
abi_name=x86_64
target_dir=''
if [[ -n ${_BUILD_CFG-} ]]; then
IFS=' ' read -r abi_name target_dir <<< ${_BUILD_CFG}
fi
if [[ -z "${target_dir}" ]]; then
target_dir="${SCRIPT_DIR}/out/$OSNAME/${BUILD_CONFIG}"
fi
if [[ -z ${NDK_ROOT+x} ]]; then
if [[ $OSTYPE == 'darwin'* ]]; then
NDK_ROOT=`ls -Ad $HOME/Library/Android/sdk/ndk/* 2>/dev/null | tail -1`
else
NDK_ROOT=`ls -Ad $HOME/Android/Sdk/ndk/* 2>/dev/null | tail -1`
fi
fi
if [[ -z "${NDK_ROOT}" ]]; then
echo "ERROR: cannot find where NDK was installed, using NDK_ROOT to specify it"
exit 7
fi
if [[ -z ${ANDROID_SDK_ROOT+x} ]]; then
export ANDROID_SDK_ROOT="$(dirname $(dirname "${NDK_ROOT}"))"
fi
if [[ -z ${ANDROID_NDK_VERSION+x} ]]; then
CURRENT_NDK_VERSION=$(basename "${NDK_ROOT}")
else
CURRENT_NDK_VERSION=${ANDROID_NDK_VERSION}
fi
# the minimum API level is 24, i.e., due to the great change of file system permission in Android 7
ANDROID_API_LEVEL=24
# build openssl and curl for azure ops
export ANDROID_API_LEVEL=${ANDROID_API_LEVEL}
export ANDROID_NDK_ROOT=${NDK_ROOT}
# pushd "${SCRIPT_DIR}/prebuild"
# ./build_curl_for_android.sh ${abi_name}
# popd
mkdir -p "${target_dir}"
pushd "${target_dir}"
cmake "$@" \
-DCMAKE_TOOLCHAIN_FILE="${NDK_ROOT}/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI=${abi_name} \
-DANDROID_PLATFORM=android-${ANDROID_API_LEVEL} \
-DANDROID_NDK_VERSION=${CURRENT_NDK_VERSION} \
-DOCOS_BUILD_ANDROID=ON \
"${SCRIPT_DIR}" && cmake --build . --config ${BUILD_CONFIG} --parallel
popd
JAVA_ROOT="${SCRIPT_DIR}/java"
pushd "${JAVA_ROOT}"
"${JAVA_ROOT}/gradlew" \
clean build publish \
--no-daemon \
-b "${JAVA_ROOT}/build-android.gradle" \
-c "${JAVA_ROOT}/settings-android.gradle" \
-DjniLibsDir="${target_dir}/java/android" \
-DbuildDir="${target_dir}/java/build/android" \
-DpublishDir="${target_dir}/aar_out" \
-DminSdkVer=${ANDROID_API_LEVEL} \
-DndkVer=${CURRENT_NDK_VERSION}
popd