-
Notifications
You must be signed in to change notification settings - Fork 1
/
build
executable file
·253 lines (212 loc) · 8.89 KB
/
build
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#!/bin/bash -e
. config.conf
BASE_FOLDER=$DOWNLOAD_DIR
PJSIP_BASE_PATH="${BASE_FOLDER}/${PJSIP_DIR_NAME}"
PJSIP_TMP_PATH="/tmp/pjsip"
CONFIG_SITE_PATH="${PJSIP_BASE_PATH}/pjlib/include/pj/config_site.h"
PJSUA_BASE_DIR="${PJSIP_TMP_PATH}/pjsip-apps/src/swig"
PJSUA_GENERATED_CSHARP_DIR="${PJSUA_BASE_DIR}/csharp/pjsua2maui/pjsua2maui/pjsua2"
PJSUA_GENERATED_JAVA_SRC_DIR="${PJSUA_BASE_DIR}/java/android/$PJSIP_GENERATED_ROOT_DIR_NAME/src/main/java"
PJSUA_GENERATED_SO_PATH="${PJSUA_BASE_DIR}/java/android/$PJSIP_GENERATED_ROOT_DIR_NAME/src/main/jniLibs"
PJSUA_GENERATED_SO_DIR="${PJSUA_BASE_DIR}/csharp/pjsua2maui/pjsua2maui.Android/lib"
FINAL_BUILD_DIR=$PJSIP_BUILD_OUT_PATH
FINAL_BUILD_LIB="${FINAL_BUILD_DIR}/lib"
FINAL_BUILD_LOGS="${FINAL_BUILD_DIR}/logs"
export ANDROID_NDK_ROOT="${BASE_FOLDER}/${NDK_DIR_NAME}"
export PATH="$ANDROID_NDK_ROOT:$PATH"
if [ "${ADD_DEBUG_SYMBOLS}" == "1" ]
then
echo "Adding compile flags for debug symbols"
export NDK_CFLAGS="-g -O2"
else
echo "Debug symbols will not be included"
fi
##############################################################################
############################ FUNCTIONS ##############################
##############################################################################
function clearBuildDirectory {
echo "Clear final build folder ..."
rm -rf "${FINAL_BUILD_DIR}"
mkdir -p "${FINAL_BUILD_LIB}"
mkdir -p "${FINAL_BUILD_LOGS}"
}
function setConfigSite {
echo "Creating config site file for Android ..."
echo "#define PJ_CONFIG_ANDROID 1" > "$CONFIG_SITE_PATH"
echo "#define PJMEDIA_HAS_G7221_CODEC 1" >> "$CONFIG_SITE_PATH"
echo "#define PJMEDIA_AUDIO_DEV_HAS_ANDROID_JNI 0" >> "$CONFIG_SITE_PATH"
echo "#define PJMEDIA_AUDIO_DEV_HAS_OPENSL 1" >> "$CONFIG_SITE_PATH"
echo "#define PJSIP_AUTH_AUTO_SEND_NEXT 0" >> "$CONFIG_SITE_PATH"
echo "#define PJMEDIA_HAS_OPUS_CODEC 1" >> "$CONFIG_SITE_PATH"
# Check the README in patches README.md for more info
if [ "${USE_FIXED_CALLID}" == "1" ]
then
echo "Changing PJSIP_MAX_URL_SIZE to 512"
echo "#define PJSIP_MAX_URL_SIZE 512" >> "$CONFIG_SITE_PATH"
fi
# If you are compiling pjsip with openssl you will likely use srtp
# in such scenario it might happen that the sdp contains srtp info
# thus the whole packet will likely exceed the default 4000 bytes.
# We are here increasing that limit to 6000 bytes.
if [ "${ENABLE_OPENSSL}" == "1" ]
then
echo "Changing PJSIP_MAX_PKT_LEN to 6000"
echo "#define PJSIP_MAX_PKT_LEN 6000" >> "$CONFIG_SITE_PATH"
else
echo "You have not enabled OpenSSL in config_site"
fi
if [ "${ENABLE_IPV6}" == "1" ]
then
echo "Enabling IPV6 in config_site"
echo "#define PJ_HAS_IPV6 1" >> "$CONFIG_SITE_PATH"
else
echo "You have not enabled IPV6 in config_site"
fi
if [ "${ENABLE_BCG729}" == "1" ]
then
echo "Enabling BCG729 in config_site"
echo "#define PJMEDIA_HAS_BCG729 1" >> "$CONFIG_SITE_PATH"
else
echo "You have not enabled BCG729 in config_site"
fi
if [ "${ENABLE_OPENH264}" == "1" ]
then
echo "Enabling Video support in config_site"
echo "#define PJMEDIA_HAS_VIDEO 1" >> "$CONFIG_SITE_PATH"
# TODO: must be tested before enabling following settings
# echo "#define PJMEDIA_VIDEO_DEV_HAS_OPENGL 1" >> "$CONFIG_SITE_PATH"
# echo "#define PJMEDIA_VIDEO_DEV_HAS_OPENGL_ES 1" >> "${CONFIG_SITE_PATH}"
# echo "#include <OpenGLES/ES3/glext.h>" >> "${CONFIG_SITE_PATH}"
else
echo "You have not enabled Video support in config_site"
fi
if [ "${CHANGE_PJSIP_TRANSPORT_IDLE_TIME}" == "1" ]
then
echo "Changing PJSIP_TRANSPORT_IDLE_TIME to $PJSIP_TRANSPORT_IDLE_TIME"
echo "#define PJSIP_TRANSPORT_IDLE_TIME $PJSIP_TRANSPORT_IDLE_TIME" >> "$CONFIG_SITE_PATH"
fi
echo "#include <pj/config_site_sample.h>" >> "$CONFIG_SITE_PATH"
}
function buildPjSip {
arch=$1
echo ""
echo "Compile PJSIP for arch $arch ..."
rm -rf "${PJSIP_TMP_PATH}"
mkdir -p "${PJSIP_TMP_PATH}"
cd "${PJSIP_BASE_PATH}"
cp -r * "${PJSIP_TMP_PATH}"
cd "${PJSIP_TMP_PATH}"
args=("--use-ndk-cflags")
if [ "${ENABLE_OPENSSL}" == "1" ]
then
echo "with OpenSSL support"
args+=("--with-ssl=${OPENSSL_BUILD_OUT_PATH}/libs/${arch}")
else
echo "without OpenSSL support"
fi
if [ "${ENABLE_OPENH264}" == "1" ]
then
echo "with OpenH264 support"
args+=("--with-openh264=${OPENH264_BUILD_OUT_PATH}/libs/${arch}")
else
echo "without OpenH264 support"
fi
if [ "${ENABLE_OPUS}" == "1" ]
then
echo "with Opus support"
args+=("--with-opus=${OPUS_BUILD_OUT_PATH}/libs/${arch}")
else
echo "without Opus support"
fi
if [ "${ENABLE_BCG729}" == "1" ]
then
echo "with BCG729 support"
args+=("--with-bcg729=${BCG729_BUILD_OUT_PATH}/libs/${arch}")
else
echo "without BCG729 support"
fi
sed -i'' -e 's/xamarin/maui/g' "${PJSUA_BASE_DIR}/csharp/Makefile"
APP_PLATFORM=android-${TARGET_ANDROID_API} TARGET_ABI=$arch ./configure-android "${args[@]}" >> "${FINAL_BUILD_LOGS}/${arch}.log" 2>&1
#make dep >>"${FINAL_BUILD_LOGS}/${arch}.log" 2>&1
#make clean >>"${FINAL_BUILD_LOGS}/${arch}.log" 2>&1
#make >>"${FINAL_BUILD_LOGS}/${arch}.log" 2>&1
make dep && make clean && make
echo "Compile PJSUA for arch $arch ..."
cd "${PJSUA_BASE_DIR}"
#make >> "${FINAL_BUILD_LOGS}/${arch}.log" 2>&1
make
echo "Copying PJSUA .so library to final build directory ..."
mkdir -p "${FINAL_BUILD_LIB}/${arch}"
# Different versions of PJSIP put .so libs in different directory name
# using /*/* we assume there is only one directory (whatever its name is)
# and retrieve all its content (.so libs)
# note: this lib only works on java bindings.
mv -v "${PJSUA_GENERATED_SO_PATH}"/*/* "${FINAL_BUILD_LIB}/${arch}"
#note: for maui bindings, use the lib generated in maui project dir
#for xamarin bindings, remove the sed command and the process is the same, copy from the xamarin dir
cp -r -v "${PJSUA_GENERATED_SO_DIR}/${arch}"/* "${FINAL}/${arch}"
if [ -f ${OPENH264_BUILD_OUT_PATH}/libs/${arch}/lib/libopenh264.so ]; then
echo "Copying OpenH264 .so library to final build directory ..."
cp -v ${OPENH264_BUILD_OUT_PATH}/libs/${arch}/lib/libopenh264.so ${FINAL_BUILD_LIB}/${arch}/
cp -v ${OPENH264_BUILD_OUT_PATH}/libs/${arch}/lib/libopenh264.so ${FINAL}/${arch}/
fi
if [ -d ${OPENSSL_BUILD_OUT_PATH}/libs/${arch}/lib/ ]; then
echo "Copying OpenSSL .so libraries to final build directory ..."
cp -v ${OPENSSL_BUILD_OUT_PATH}/libs/${arch}/lib/libssl.so ${FINAL_BUILD_LIB}/${arch}/
cp -v ${OPENSSL_BUILD_OUT_PATH}/libs/${arch}/lib/libcrypto.so ${FINAL_BUILD_LIB}/${arch}/
fi
ls /home/runner/libpjsua2/lib/*/*
# cp -f /home/tools/android-ndk-r21e/sources/cxx-stl/llvm-libc++/libs/${arch}/libc++_shared.so ${FINAL_BUILD_LIB}/${arch}/
}
function copyPjsuaBindings {
echo "Copying PJSUA2 java and csharp bindings to final build directory ..."
cp -r -v "${PJSUA_GENERATED_JAVA_SRC_DIR}" "${FINAL}"
if [ -d ${PJSUA_GENERATED_CSHARP_DIR}/ ]; then
echo "Copying c# sources to final build directory ..."
if [ ! -d ${FINAL}/libpjsua2.maui.android ]; then
mkdir -p ${FINAL}/libpjsua2.maui.android
cp -v ${PJSUA_GENERATED_CSHARP_DIR}/*.cs ${FINAL}/libpjsua2.maui.android
fi
fi
}
function clearToolsDirectory {
if [ "$REMOVE_TOOLS" == "1" ]
then
echo ""
echo "Cleaning up tools ..."
cd $BASEDIR
rm -r tools
echo "Finished cleaning up tools"
fi
}
function setPermissions {
if [ "$SET_PERMISSIONS" == "1" ] && [ "$OWNER" != "" ]
then
echo ""
echo "Setting permissions on $BUILD_DIR for user $OWNER"
chown $OWNER -R $BUILD_DIR
echo "Finished Setting permissions"
elif [ "$SET_PERMISSIONS" == "1" ] || [ "$OWNER" != "" ]
then
echo "You must set both the toggle [SET_PERMISSIONS] to 1 and the name of the user [OWNER] that should own the files"
fi
}
##############################################################################
############################ MAIN ############################
##############################################################################
# Clearing the build output directory
clearBuildDirectory
# Create config_site file
setConfigSite
# Build PjSip for each ARCH specified in config.conf
for arch in "${TARGET_ARCHS[@]}"
do
buildPjSip $arch
done
# Copy PjSua Bindings into final build output directory
copyPjsuaBindings
# Delete the tools directory
#clearToolsDirectory
# Setting Permission on build output directory
# setPermissions
echo "Finished! Check the generated output in ${FINAL_BUILD_DIR}"