forked from monero-project/monero-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_libwallet_api.sh
executable file
·248 lines (212 loc) · 8.76 KB
/
get_libwallet_api.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
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
#!/bin/bash
LOKI_URL=https://github.com/loki-project/loki.git
LOKI_BRANCH=master
pushd $(pwd)
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $ROOT_DIR/utils.sh
INSTALL_DIR=$ROOT_DIR/wallet
LOKI_DIR=$ROOT_DIR/loki
BUILD_LIBWALLET=false
# init and update loki submodule
if [ ! -d $LOKI_DIR/src ]; then
git submodule init loki
fi
git submodule update --remote
git -C $LOKI_DIR fetch
# git -C $LOKI_DIR checkout v0.12.0.0
# get loki core tag
get_tag
# create local loki branch
git -C $LOKI_DIR checkout -B $VERSIONTAG
git -C $LOKI_DIR submodule init
git -C $LOKI_DIR submodule update
# Merge loki PR dependencies
# Workaround for git username requirements
# Save current user settings and revert back when we are done with merging PR's
OLD_GIT_USER=$(git -C $LOKI_DIR config --local user.name)
OLD_GIT_EMAIL=$(git -C $LOKI_DIR config --local user.email)
git -C $LOKI_DIR config user.name "Loki GUI"
git -C $LOKI_DIR config user.email "gui@loki.local"
# check for PR requirements in most recent commit message (i.e requires #xxxx)
for PR in $(git log --format=%B -n 1 | grep -io "requires #[0-9]*" | sed 's/[^0-9]*//g'); do
echo "Merging loki push request #$PR"
# fetch pull request and merge
git -C $LOKI_DIR fetch origin pull/$PR/head:PR-$PR
git -C $LOKI_DIR merge --quiet PR-$PR -m "Merge loki PR #$PR"
BUILD_LIBWALLET=true
done
# revert back to old git config
$(git -C $LOKI_DIR config user.name "$OLD_GIT_USER")
$(git -C $LOKI_DIR config user.email "$OLD_GIT_EMAIL")
# Build libwallet if it doesnt exist
if [ ! -f $LOKI_DIR/lib/libwallet_merged.a ]; then
echo "libwallet_merged.a not found - Building libwallet"
BUILD_LIBWALLET=true
# Build libwallet if no previous version file exists
elif [ ! -f $LOKI_DIR/version.sh ]; then
echo "loki/version.h not found - Building libwallet"
BUILD_LIBWALLET=true
## Compare previously built version with submodule + merged PR's version.
else
source $LOKI_DIR/version.sh
# compare submodule version with latest build
pushd "$LOKI_DIR"
get_tag
popd
echo "latest libwallet version: $GUI_LOKI_VERSION"
echo "Installed libwallet version: $VERSIONTAG"
# check if recent
if [ "$VERSIONTAG" != "$GUI_LOKI_VERSION" ]; then
echo "Building new libwallet version $GUI_LOKI_VERSION"
BUILD_LIBWALLET=true
else
echo "latest libwallet ($GUI_LOKI_VERSION) is already built. Remove loki/lib/libwallet_merged.a to force rebuild"
fi
fi
if [ "$BUILD_LIBWALLET" != true ]; then
# exit this script
return
fi
echo "GUI_LOKI_VERSION=\"$VERSIONTAG\"" > $LOKI_DIR/version.sh
## Continue building libwallet
# default build type
BUILD_TYPE=$1
if [ -z $BUILD_TYPE ]; then
BUILD_TYPE=release
fi
STATIC=false
ANDROID=false
if [ "$BUILD_TYPE" == "release" ]; then
echo "Building libwallet release"
CMAKE_BUILD_TYPE=Release
elif [ "$BUILD_TYPE" == "release-static" ]; then
echo "Building libwallet release-static"
CMAKE_BUILD_TYPE=Release
STATIC=true
elif [ "$BUILD_TYPE" == "release-android" ]; then
echo "Building libwallet release-static for ANDROID"
CMAKE_BUILD_TYPE=Release
STATIC=true
ANDROID=true
elif [ "$BUILD_TYPE" == "debug-android" ]; then
echo "Building libwallet debug-static for ANDROID"
CMAKE_BUILD_TYPE=Debug
STATIC=true
ANDROID=true
elif [ "$BUILD_TYPE" == "debug" ]; then
echo "Building libwallet debug"
CMAKE_BUILD_TYPE=Debug
STATIC=true
else
echo "Valid build types are release, release-static, release-android, debug-android and debug"
exit 1;
fi
echo "cleaning up existing loki build dir, libs and includes"
rm -fr $LOKI_DIR/build
rm -fr $LOKI_DIR/lib
rm -fr $LOKI_DIR/include
rm -fr $LOKI_DIR/bin
mkdir -p $LOKI_DIR/build/$BUILD_TYPE
pushd $LOKI_DIR/build/$BUILD_TYPE
# reusing function from "utils.sh"
platform=$(get_platform)
# default make executable
make_exec="make"
## OS X
if [ "$platform" == "darwin" ]; then
echo "Configuring build for MacOS.."
if [ "$STATIC" == true ]; then
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" ../..
else
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" ../..
fi
## LINUX 64
elif [ "$platform" == "linux64" ]; then
echo "Configuring build for Linux x64"
if [ "$ANDROID" == true ]; then
echo "Configuring build for Android on Linux host"
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D ARCH="armv7-a" -D ANDROID=true -D BUILD_GUI_DEPS=ON -D USE_LTO=OFF -D INSTALL_VENDORED_LIBUNBOUND=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" ../..
elif [ "$STATIC" == true ]; then
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" ../..
else
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" ../..
fi
## LINUX 32
elif [ "$platform" == "linux32" ]; then
echo "Configuring build for Linux i686"
if [ "$STATIC" == true ]; then
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D ARCH="i686" -D BUILD_64=OFF -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" ../..
else
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" ../..
fi
## LINUX ARMv7
elif [ "$platform" == "linuxarmv7" ]; then
echo "Configuring build for Linux armv7"
if [ "$STATIC" == true ]; then
cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D STATIC=ON -D BUILD_64=OFF -D BUILD_GUI_DEPS=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" ../..
else
cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D -D BUILD_64=OFF -D BUILD_GUI_DEPS=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" ../..
fi
## LINUX other
elif [ "$platform" == "linux" ]; then
echo "Configuring build for Linux general"
if [ "$STATIC" == true ]; then
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" ../..
else
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" ../..
fi
## Windows 64
## Windows is always static to work outside msys2
elif [ "$platform" == "mingw64" ]; then
# Do something under Windows NT platform
echo "Configuring build for MINGW64.."
BOOST_ROOT=/mingw64/boost
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D BOOST_ROOT="$BOOST_ROOT" -D ARCH="x86-64" -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" -G "MSYS Makefiles" ../..
## Windows 32
elif [ "$platform" == "mingw32" ]; then
# Do something under Windows NT platform
echo "Configuring build for MINGW32.."
BOOST_ROOT=/mingw32/boost
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D Boost_DEBUG=ON -D BOOST_ROOT="$BOOST_ROOT" -D ARCH="i686" -D BUILD_64=OFF -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" -G "MSYS Makefiles" ../..
make_exec="mingw32-make"
else
echo "Unknown platform, configuring general build"
if [ "$STATIC" == true ]; then
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D BUILD_GUI_DEPS=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" ../..
else
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON -D CMAKE_INSTALL_PREFIX="$LOKI_DIR" ../..
fi
fi
# set CPU core count
# thanks to SO: http://stackoverflow.com/a/20283965/4118915
if test -z "$CPU_CORE_COUNT"; then
CPU_CORE_COUNT=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
fi
# Build libwallet_merged
pushd $LOKI_DIR/build/$BUILD_TYPE/src/wallet
eval $make_exec version -C ../..
eval $make_exec -j$CPU_CORE_COUNT
eval $make_exec install -j$CPU_CORE_COUNT
popd
# Build lokid
# win32 need to build daemon manually with msys2 toolchain
if [ "$platform" != "mingw32" ] && [ "$ANDROID" != true ]; then
pushd $LOKI_DIR/build/$BUILD_TYPE/src/daemon
eval make -j$CPU_CORE_COUNT
eval make install -j$CPU_CORE_COUNT
popd
fi
# build install epee
eval make -C $LOKI_DIR/build/$BUILD_TYPE/contrib/epee all install
# install easylogging
eval make -C $LOKI_DIR/build/$BUILD_TYPE/external/easylogging++ all install
# install lmdb
eval make -C $LOKI_DIR/build/$BUILD_TYPE/external/db_drivers/liblmdb all install
# Install libunbound
echo "Installing libunbound..."
pushd $LOKI_DIR/build/$BUILD_TYPE/external/unbound
# no need to make, it was already built as dependency for libwallet
# make -j$CPU_CORE_COUNT
$make_exec install -j$CPU_CORE_COUNT
popd
popd