/
build-libs.sh
executable file
·57 lines (46 loc) · 1003 Bytes
/
build-libs.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
#!/bin/bash
if [[ -z "${ANDROID_NDK_HOME}" ]]; then
echo "ANDROID_NDK_HOME must be set! android-ndk-r21e is confirmed to work, but other version can also work."
echo "get it from here: https://developer.android.com/ndk/downloads"
exit 1
fi
ARGS=$(getopt -o "dca" -l "debug,clean,archive" -n "build-libs.sh" -- "$@");
eval set -- "$ARGS";
cd libserial/src/main
JNI_ARGS="NDK_LIBS_OUT=jniLibs"
BUILD_TASK="assembleRelease"
EXPORT_AAR=1
while true; do
case "$1" in
-d|--debug)
shift
JNI_ARGS="$JNI_ARGS NDK_DEBUG=1"
BUILD_TASK="assembleDebug"
break;
;;
-c|--clean)
shift
JNI_ARGS="$JNI_ARGS clean"
break;
;;
-a|--archive)
shift
EXPORT_AAR=1
break;
;;
--)
shift
break;
;;
esac
done
# Remove '--'
shift
ndk-build $JNI_ARGS
cd ../../..
if [ "$EXPORT_AAR" = "1" ]; then
cd libserial
../gradlew $BUILD_TASK
cd ..
echo "Done, output is at libserial/build/outputs/aar"
fi