-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·85 lines (71 loc) · 2.06 KB
/
build.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
#!/bin/bash
sigfile=`ls -1 libsodium-*-stable.tar.gz.minisig`
srcfile=`basename $sigfile .minisig`
srcdir='libsodium-stable'
# --------------------------
# Download and verify source
# --------------------------
[ -f $srcfile ] && rm -f $srcfile
curl https://download.libsodium.org/libsodium/releases/$srcfile > $srcfile
minisign -P "RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3" -Vm $srcfile || exit 1
# --------------------------
# Extract sources
# --------------------------
[ -e $srcdir ] && rm -Rf $srcdir
tar -xzf $srcfile
cd $srcdir
targetPlatforms="$@"
[ "$targetPlatforms" ] || targetPlatforms="arm x86 ios"
for targetPlatform in $targetPlatforms
do
# --------------------------
# iOS build
# --------------------------
platform=`uname`
if [ "$platform" == 'Darwin' ] && [ "$targetPlatform" == 'ios' ]; then
IOS_VERSION_MIN=10.0.0 dist-build/apple-xcframework.sh
fi
# # --------------------------
# # Android build
# # --------------------------
case $targetPlatform in
"arm-old")
NDK_PLATFORM=android-21 dist-build/android-arm.sh
;;
"arm")
NDK_PLATFORM=android-21 dist-build/android-armv7-a.sh
NDK_PLATFORM=android-21 dist-build/android-armv8-a.sh
;;
"mips")
NDK_PLATFORM=android-21 dist-build/android-mips32.sh
NDK_PLATFORM=android-21 dist-build/android-mips64.sh
;;
"x86")
NDK_PLATFORM=android-21 dist-build/android-x86.sh
NDK_PLATFORM=android-21 dist-build/android-x86_64.sh
;;
esac
done
cd ..
# --------------------------
# Move compiled libraries
# --------------------------
mkdir -p libsodium
rm -Rf libsodium/*
for dir in $srcdir/libsodium-android-*
do
mv $dir libsodium/
done
if [ "$platform" == 'Darwin' ] && [ -e $srcdir/libsodium-apple ]; then
echo $PWD
mv $srcdir/libsodium-apple libsodium/
fi
# --------------------------
# Update precompiled.tgz
# --------------------------
tar -cvzf precompiled.tgz libsodium
# --------------------------
# Cleanup
# --------------------------
[ -e $srcdir ] && rm -Rf $srcdir
[ -e $srcfile ] && rm $srcfile