-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_android.sh
executable file
·64 lines (54 loc) · 1.94 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
56
57
58
59
60
61
62
63
#!/bin/bash
export NDK_HOME="/home/zrji/android_caffe/tmp_ndk/android-ndk-r18b"
export DEVICE_OPENCL_DIR="/home/zrji/android_caffe/caffe-android-opencl/third_party/OpenCL/"
if [ ! -d "$NDK_HOME" ]; then
echo "$(tput setaf 2)"
echo "###########################################################"
echo " ERROR: Invalid NDK_HOME=\"$NDK_HOME\" env variable, exit. "
echo "###########################################################"
echo "$(tput sgr0)"
exit 1
fi
if [ ! -d "$DEVICE_OPENCL_DIR" ]; then
echo "$(tput setaf 2)"
echo "###########################################################"
echo " ERROR: Invalid DEVICE_OPENCL_DIR=\"$DEVICE_OPENCL_DIR\" env variable, exit. "
echo "###########################################################"
echo "$(tput sgr0)"
exit 1
fi
ANDROID_ABIs=("arm64-v8a")
function build-abi {
cd third_party
# ./build-protobuf-3.1.0.sh Android || exit 1
#exit 1
./build-openblas.sh Android || exit 1
#exit 1
./build-clblast.sh || exit 1
mkdir ../build_${ANDROID_ABI%% *}
cd ../build_${ANDROID_ABI%% *} || exit 1
rm -rf *
cmake .. -DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_NDK=$NDK_HOME \
-DANDROID_ABI="$ANDROID_ABI" \
-DANDROID_NATIVE_API_LEVEL=$ANDROID_NATIVE_API_LEVEL \
-DOPENCL_ROOT=$DEVICE_OPENCL_DIR \
-G "Unix Makefiles" || exit 1
make -j 40 || exit 1
# cd ../examples/android/CaffeSimple/app/
# mkdir -p libs/${ANDROID_ABI%% *}
# ln -sf ../../../../../../build_${ANDROID_ABI%% *}/lib/libcaffe-jni.so libs/${ANDROID_ABI%% *}/libcaffe-jni.so
# cd ../../../..
}
IFS=""
for abi in ${ANDROID_ABIs[@]}; do
export ANDROID_ABI="$abi"
if [ "$ANDROID_ABI" = "arm64-v8a" ]; then
export ANDROID_NATIVE_API_LEVEL=28
else
export ANDROID_NATIVE_API_LEVEL=16
fi
echo $ANDROID_ABI
echo $ANDROID_NATIVE_API_LEVEL
build-abi
done