-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild-android.sh
executable file
·55 lines (44 loc) · 1.37 KB
/
build-android.sh
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
#!/usr/bin/env bash
CMAKE=""
build_anthy() {
echo ">>> Building anthy for $1"
"$CMAKE" -B build \
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_ROOT"/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="$1" \
-DANDROID_PLATFORM="$ANDROID_PLATFORM" \
-DANDROID_STL=c++_shared \
-DCMAKE_INSTALL_PREFIX=out/anthy/"$1" \
.
"$CMAKE" --build build
"$CMAKE" --build build --target install
rm -rf ./build
}
if [ -z "${ANDROID_SDK_ROOT}" ]; then
echo "ANDROID_SDK_ROOT should be set to Android SDK path."
exit 1
fi
if [ -z "${ANDROID_NDK_ROOT}" ]; then
echo "ANDROID_NDK_ROOT should be set to Android NDK path."
exit 1
fi
if [ -z "${ANDROID_SDK_CMAKE_VERSION}" ]; then
echo "ANDROID_SDK_CMAKE_VERSION should be set to desired cmake version in \$ANDROID_SDK_ROOT/cmake. eg. 3.18.1"
exit 1
fi
if [ -z "${ANDROID_PLATFORM}" ]; then
echo "ANDROID_PLATFORM should be set to minimum API level supported by the library. eg. 21"
exit 1
fi
if [ -z "${ANDROID_ABI}" ]; then
echo "ANDROID_ABI not set; can be a ',' separated list. eg. armeabi-v7a,arm64-v8a"
exit 1
fi
CMAKE="$ANDROID_SDK_ROOT/cmake/$ANDROID_SDK_CMAKE_VERSION/bin/cmake"
if [ ! -f "$CMAKE" ]; then
echo "Cannot find cmake: '$CMAKE'"
exit 1
fi
IFS=',' read -ra ARCH <<< "${ANDROID_ABI}"
for a in "${ARCH[@]}"; do
build_anthy "$a"
done