This repository has been archived by the owner on Oct 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup.sh
executable file
·124 lines (94 loc) · 2.08 KB
/
setup.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
#!/bin/bash
set -e
set -x
# Android NDK r12b
export NDK_VERSION="android-ndk-r14b"
export NDK_OSFAMILY="linux"
export SWIG_VERSION="swig-3.0.8"
export NDK_PLATFORM="android-9"
# Require JAVA_HOME
if [ -z "$JAVA_HOME" ]; then
echo "ERROR You should set JAVA_HOME"
echo "example: \`export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64\`"
echo "Exiting!"
exit 1
fi
function ndk_setup {
ARCH=$(uname -m)
if [ $ARCH != "x86_64" ]; then
$ARCH = "x86"
fi
echo "Downloading NDK for ${ARCH}"
ZIP="${NDK_VERSION}-${NDK_OSFAMILY}-${ARCH}.zip"
wget https://dl.google.com/android/repository/${ZIP}
unzip ${ZIP}
export ANDROID_NDK_HOME=${PWD}/${NDK_VERSION}
}
function ndk_cleanup {
rm -rf ${NDK_VERSION}*
}
#
# SWIG 2.0
#
function swig_setup {
cd jni
wget https://prdownloads.sourceforge.net/swig/${SWIG_VERSION}.tar.gz
tar -xvf ${SWIG_VERSION}.tar.gz
cd ${SWIG_VERSION}
./autogen.sh
./configure
make -j 5
sudo make install
cd ../..
}
function swig_cleanup {
cd jni
rm -rf ${SWIG_VERSION}*
cd ..
}
#
# install libsodium from the repository
#
function setup_libsodium {
rm -rf libsodium
git submodule init
git submodule update
cd libsodium
# use stable branch
# git fetch && git checkout origin/stable
./autogen.sh
# Build local
./configure
make && make check
sudo make install
sudo ldconfig
# Disable minimal in android builds
sed --in-place '/--enable-minimal/d' ./dist-build/android-build.sh
# Build android
./dist-build/android-arm.sh
./dist-build/android-armv7-a.sh
./dist-build/android-mips32.sh
./dist-build/android-x86.sh
cd ..
}
# Install swig and compile the JNI with libsodium
function compile_jni {
cd jni
./compile.sh
export PATH=$PATH:$ANDROID_NDK_HOME
ndk-build clean
ndk-build
cd ..
}
# Add auto-cleanup before the script runs
ndk_cleanup
#swig_cleanup
# Download and install
ndk_setup
#swig_setup
# Compile the libraries
setup_libsodium
compile_jni
# Cleanup
ndk_cleanup
#swig_cleanup