-
-
Notifications
You must be signed in to change notification settings - Fork 108
/
build_android.sh
executable file
·136 lines (115 loc) · 3.91 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
function help()
{
echo "Please set environment value ANDROID_NDK"
echo "$0 QT_ROOT ThirdLibs_DIR RabbitCommon_DIR ENABLE_DOWNLOAD"
exit -1
}
if [ -n "$1" ]; then
QT_ROOT=$1
fi
if [ ! -f $QT_ROOT/bin/qmake ]; then
help
fi
if [ -n "$2" ]; then
export ThirdLibs_DIR=$2
fi
if [ ! -d "$ThirdLibs_DIR" ]; then
help
fi
if [ -n "${ThirdLibs_DIR}" ]; then
export SeetaFace_DIR=${SeetaFace_DIR}/lib/cmake
export OpenCV_DIR=${ThirdLibs_DIR}/sdk/native/jni
export protobuf_DIR=${ThirdLibs_DIR}/lib/cmake/protobuf
export facedetection_DIR=${ThirdLibs_DIR}/lib/cmake/facedetection
export dlib_DIR=${ThirdLibs_DIR}/lib/cmake/dlib
export ncnn_DIR=${ThirdLibs_DIR}/lib/cmake/ncnn
export FFMPEG_DIR=${SeetaFace_DIR}
export YUV_DIR=${ThirdLibs_DIR}/lib/cmake
fi
if [ -n "$3" -a -z "$RabbitCommon_DIR" ]; then
RabbitCommon_DIR=$3
fi
if [ -z "$RabbitCommon_DIR" ]; then
RabbitCommon_DIR=`pwd`/../RabbitCommon
fi
if [ ! -d "$RabbitCommon_DIR" ]; then
help
fi
if [ -n "$4" ]; then
export ENABLE_DOWNLOAD=$4
fi
if [ -z "$ENABLE_DOWNLOAD" ]; then
export ENABLE_DOWNLOAD=OFF
fi
export RabbitCommon_DIR=$RabbitCommon_DIR
export QT_ROOT=$QT_ROOT
export PATH=$QT_ROOT/bin:$PATH
ANDROID_ARM_NEON=OFF
if [ -z "$ANDROID_NDK" ]; then
help
fi
if [ -n "$QT_ROOT" ]; then
PARA="${PARA} -DQt5_DIR=${QT_ROOT}/lib/cmake/Qt5
-DQt5Core_DIR=${QT_ROOT}/lib/cmake/Qt5Core
-DQt5Gui_DIR=${QT_ROOT}/lib/cmake/Qt5Gui
-DQt5Widgets_DIR=${QT_ROOT}/lib/cmake/Qt5Widgets
-DQt5Xml_DIR=${QT_ROOT}/lib/cmake/Qt5Xml
-DQt5Network_DIR=${QT_ROOT}/lib/cmake/Qt5Network
-DQt5Multimedia_DIR=${QT_ROOT}/lib/cmake/Qt5Multimedia
-DQt5Sql_DIR=${QT_ROOT}/lib/cmake/Qt5Sql
-DQt5LinguistTools_DIR=${QT_ROOT}/lib/cmake/Qt5LinguistTools
-DQt5AndroidExtras_DIR=${QT_ROOT}/lib/cmake/Qt5AndroidExtras"
fi
if [ -d "${ThirdLibs_DIR}" ]; then
PARA="${PARA} -DYUV_DIR=${YUV_DIR}"
PARA="${PARA} -DOPENSSL_ROOT_DIR=${ThirdLibs_DIR}"
PARA="${PARA} -Ddlib_DIR=${ThirdLibs_DIR}/lib/cmake/dlib"
PARA="${PARA} -Dncnn_DIR=${ThirdLibs_DIR}/lib/cmake/ncnn"
PARA="${PARA} -Dfacedetection_DIR=${ThirdLibs_DIR}/lib/cmake/facedetection"
PARA="${PARA} -DOpenCV_DIR=${OpenCV_DIR}"
PARA="${PARA} -Dprotobuf_DIR=${ThirdLibs_DIR}/lib/cmake/protobuf"
PARA="${PARA} -DFFMPEG_DIR=${FFMPEG_DIR}"
export OPENSSL_ROOT_DIR=${ThirdLibs_DIR}
PARA="${PARA} -DSeetaFace_DIR=${ThirdLibs_DIR}/lib/cmake
-DSeetaNet_DIR=${ThirdLibs_DIR}/lib/cmake
-DSeetaFaceDetector_DIR=${ThirdLibs_DIR}/lib/cmake
-DSeetaFaceLandmarker_DIR=${ThirdLibs_DIR}/lib/cmake
-DSeetaFaceRecognizer_DIR=${ThirdLibs_DIR}/lib/cmake
-DSeetaFaceTracker_DIR=${ThirdLibs_DIR}/lib/cmake
-DSeetaQualityAssessor_DIR=${ThirdLibs_DIR}/lib/cmake "
fi
if [ -z "$FFMPEG_DIR" ]; then
PARA="${PARA} -DUSE_FFMPEG=OFF"
fi
if [ -z "$YUV_DIR" ]; then
PARA="${PARA} -DUSE_YUV=OFF"
fi
if [ -z "$OpenCV_DIR" ]; then
PARA="${PARA} -DUSE_OPENCV=OFF"
fi
if [ -z "$ANDROID_ABI" ]; then
ANDROID_ABI="arm64-v8a"
ANDROID_ARM_NEON=ON
fi
if [ -z "${ANDROID_PLATFORM}" ]; then
ANDROID_PLATFORM="android-24"
fi
echo "PARA:$PARA"
if [ ! -d build_android ]; then
mkdir -p build_android
fi
cd build_android
cmake .. -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=`pwd`/android-build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_VERBOSE_MAKEFILE=TRUE \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="${ANDROID_ABI}" \
-DANDROID_ARM_NEON=${ANDROID_ARM_NEON} \
-DBUILD_PERFORMANCE=ON \
-DANDROID_PLATFORM=${ANDROID_PLATFORM} ${PARA}
cmake --build . --config Release -- -j`cat /proc/cpuinfo |grep 'cpu cores' |wc -l`
cmake --build . --config Release --target install/strip
#-- -j`cat /proc/cpuinfo |grep 'cpu cores' |wc -l`
cmake --build . --config Release --target APK
cd ..