forked from netpyoung/unity.libsodium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-on-mac.sh
81 lines (61 loc) · 2.34 KB
/
build-on-mac.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
#!/usr/bin/env bash
# ===========================
# macOs, iOs
# ===========================
# [brew] install dependencies
packages='libtool autoconf automake wget'
brew update
for pkg in ${packages}; do
if brew list -1 | grep -q "^${pkg}\$"; then
echo "Package '$pkg' is installed"
#brew upgrade $pkg
else
echo "Package '$pkg' is not installed"
brew install $pkg
fi
done
brew upgrade ${packages} || true
# [variable]
ROOT=$(pwd)
DIR_DEST=${ROOT}/output
DIR_LIBSODIUM=${ROOT}/libsodium
# [src] libsodium
git clone https://github.com/jedisct1/libsodium.git $DIR_LIBSODIUM && cd $DIR_LIBSODIUM
./autogen.sh
# [generate]
cd $DIR_LIBSODIUM
./dist-build/ios.sh
./dist-build/osx.sh
mkdir -p $DIR_DEST/Plugins/iOs
mkdir -p $DIR_DEST/Plugins/x64
cp $DIR_LIBSODIUM/libsodium-ios/lib/libsodium.a $DIR_DEST/Plugins/iOS/libsodium.a
cp $DIR_LIBSODIUM/libsodium-osx/lib/libsodium.*.dylib $DIR_DEST/Plugins/x64/sodium.bundle
# ===========================
# Android
# ===========================
# [environment]
export ANDROID_NDK_HOME=${ROOT}/android-ndk
DIR_TEMP=${ROOT}/temp_dir
# [sdk] Android NDK
mkdir $DIR_TEMP && cd $DIR_TEMP
wget -q https://dl.google.com/android/repository/android-ndk-r13b-darwin-x86_64.zip
unzip -o -q android-ndk-r13b-darwin-x86_64.zip
mv $DIR_TEMP/android-ndk-r13b ${ANDROID_NDK_HOME}
# [generate]
cd $DIR_LIBSODIUM
./dist-build/android-armv7-a.sh
./dist-build/android-x86.sh
mkdir -p $DIR_DEST/Plugins/Android/libs/armeabi-v7a
mv $DIR_LIBSODIUM/libsodium-android-armv7-a/lib/libsodium.a $DIR_LIBSODIUM/libsodium-android-armv7-a/lib/libsodium.so $DIR_DEST/Plugins/Android/libs/armeabi-v7a
mkdir -p $DIR_DEST/Plugins/Android/libs/x86
mv $DIR_LIBSODIUM/libsodium-android-i686/lib/libsodium.a $DIR_LIBSODIUM/libsodium-android-i686/lib/libsodium.so $DIR_DEST/Plugins/Android/libs/x86
# ===========================
# Windows
# ===========================
DIR_MSVC=${ROOT}/msvc
wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.16-msvc.zip
unzip libsodium-1.0.16-msvc.zip -d ${DIR_MSVC}
mkdir -p ${DIR_DEST}/Plugins/x86
mkdir -p ${DIR_DEST}/Plugins/x64
cp ${DIR_MSVC}/Win32/Debug/v140/dynamic/libsodium.dll ${DIR_MSVC}/Win32/Debug/v140/dynamic/libsodium.pdb ${DIR_DEST}/Plugins/x86
cp ${DIR_MSVC}/x64/Debug/v140/dynamic/libsodium.dll ${DIR_MSVC}/x64/Debug/v140/dynamic/libsodium.pdb ${DIR_DEST}/Plugins/x64