-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheosio_build_darwin.sh
541 lines (515 loc) · 16.7 KB
/
eosio_build_darwin.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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
OS_VER=$(sw_vers -productVersion)
OS_MAJ=$(echo "${OS_VER}" | cut -d'.' -f1)
OS_MIN=$(echo "${OS_VER}" | cut -d'.' -f2)
OS_PATCH=$(echo "${OS_VER}" | cut -d'.' -f3)
MEM_GIG=$(bc <<< "($(sysctl -in hw.memsize) / 1024000000)")
CPU_SPEED=$(bc <<< "scale=2; ($(sysctl -in hw.cpufrequency) / 10^8) / 10")
CPU_CORE=$( sysctl -in machdep.cpu.core_count )
DISK_INSTALL=$(df -h . | tail -1 | tr -s ' ' | cut -d\ -f1 || cut -d' ' -f1)
blksize=$(df . | head -1 | awk '{print $2}' | cut -d- -f1)
gbfactor=$(( 1073741824 / blksize ))
total_blks=$(df . | tail -1 | awk '{print $2}')
avail_blks=$(df . | tail -1 | awk '{print $4}')
DISK_TOTAL=$((total_blks / gbfactor ))
DISK_AVAIL=$((avail_blks / gbfactor ))
printf "\\n\\tOS name: %s\\n" "${ARCH}"
printf "\\tOS Version: %s\\n" "${OS_VER}"
printf "\\tCPU speed: %sGhz\\n" "${CPU_SPEED}"
printf "\\tCPU cores: %s\\n" "${CPU_CORE}"
printf "\\tPhysical Memory: %s Gbytes\\n" "${MEM_GIG}"
printf "\\tDisk install: %s\\n" "${DISK_INSTALL}"
printf "\\tDisk space total: %sG\\n" "${DISK_TOTAL}"
printf "\\tDisk space available: %sG\\n\\n" "${DISK_AVAIL}"
if [ "${MEM_GIG}" -lt 7 ]; then
echo "Your system must have 7 or more Gigabytes of physical memory installed."
echo "Exiting now."
exit 1
fi
if [ "${OS_MIN}" -lt 12 ]; then
echo "You must be running Mac OS 10.12.x or higher to install EOSIO."
echo "Exiting now."
exit 1
fi
if [ "${DISK_AVAIL}" -lt "$DISK_MIN" ]; then
echo "You must have at least ${DISK_MIN}GB of available storage to install EOSIO."
echo "Exiting now."
exit 1
fi
printf "\\tChecking xcode-select installation\\n"
if ! XCODESELECT=$( command -v xcode-select)
then
printf "\\n\\tXCode must be installed in order to proceed.\\n\\n"
printf "\\tExiting now.\\n"
exit 1
fi
printf "\\txcode-select installation found @ \\n"
printf "\\t%s \\n\\n" "${XCODESELECT}"
printf "\\tChecking Ruby installation.\\n"
if ! RUBY=$( command -v ruby)
then
printf "\\nRuby must be installed in order to proceed.\\n\\n"
printf "\\tExiting now.\\n"
exit 1
fi
printf "\\tRuby installation found @ \\n"
printf "\\t%s \\n\\n" "${RUBY}"
printf "\\tChecking Home Brew installation\\n"
if ! BREW=$( command -v brew )
then
printf "\\tHomebrew must be installed to compile EOS.IO\\n\\n"
printf "\\tDo you wish to install Home Brew?\\n"
select yn in "Yes" "No"; do
case "${yn}" in
[Yy]* )
"${XCODESELECT}" --install 2>/dev/null;
if ! "${RUBY}" -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
then
echo "Unable to install homebrew at this time. Exiting now."
exit 1;
else
BREW=$( command -v brew )
fi
break;;
[Nn]* ) echo "User aborted homebrew installation. Exiting now.";
exit 1;;
* ) echo "Please enter 1 for yes or 2 for no.";;
esac
done
fi
printf "\\tHome Brew installation found @\\n"
printf "\\t%s\\n\\n" "${BREW}"
COUNT=1
PERMISSION_GETTEXT=0
DISPLAY=""
DEP=""
printf "\\tChecking dependencies.\\n"
var_ifs="${IFS}"
IFS=","
while read -r name tester testee brewname uri
do
printf "\\tChecking %s ... " "${name}"
if [ "${tester}" "${testee}" ]; then
printf "\\t\\t %s found\\n" "${name}"
continue
fi
# resolve conflict with homebrew glibtool and apple/gnu installs of libtool
if [ "${testee}" == "/usr/local/bin/glibtool" ]; then
if [ "${tester}" "/usr/local/bin/libtool" ]; then
printf "\\t\\t %s found\\n" "${name}"
continue
fi
fi
if [ "${brewname}" = "gettext" ]; then
PERMISSION_GETTEXT=1
fi
DEP=$DEP"${brewname} "
DISPLAY="${DISPLAY}${COUNT}. ${name}\\n\\t"
printf "\\t\\t %s ${bldred}NOT${txtrst} found.\\n" "${name}"
(( COUNT++ ))
done < "${SOURCE_DIR}/scripts/eosio_build_dep"
IFS="${var_ifs}"
printf "\\tChecking Python3 ... "
if [ -z "$( python3 -c 'import sys; print(sys.version_info.major)' 2>/dev/null )" ]; then
DEP=$DEP"python@3 "
DISPLAY="${DISPLAY}${COUNT}. Python 3\\n\\t"
printf "\\t\\t python3 ${bldred}NOT${txtrst} found.\\n"
(( COUNT++ ))
else
printf "\\t\\t Python3 found\\n"
fi
if [ $COUNT -gt 1 ]; then
printf "\\n\\tThe following dependencies are required to install EOSIO.\\n"
printf "\\n\\t${DISPLAY}\\n\\n"
echo "Do you wish to install these packages?"
select yn in "Yes" "No"; do
case $yn in
[Yy]* )
if [ $PERMISSION_GETTEXT -eq 1 ]; then
sudo chown -R "$(whoami)" /usr/local/share
fi
"${XCODESELECT}" --install 2>/dev/null;
printf "\\tUpdating Home Brew.\\n"
if ! brew update
then
printf "\\tUnable to update Home Brew at this time.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
printf "\\tInstalling Dependencies.\\n"
if ! "${BREW}" install --force ${DEP}
then
printf "\\tHomebrew exited with the above errors.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! "${BREW}" unlink {DEP} && "${BREW}" link --force ${DEP}
then
printf "\\tHomebrew exited with the above errors.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
break;;
[Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;;
* ) echo "Please type 1 for yes or 2 for no.";;
esac
done
else
printf "\\n\\tNo required Home Brew dependencies to install.\\n"
fi
printf "\\n\\tChecking boost library installation.\\n"
BVERSION=$( grep "#define BOOST_VERSION" "/usr/local/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\ -f3 )
if [ "${BVERSION}" != "106700" ]; then
if [ ! -z "${BVERSION}" ]; then
printf "\\tFound Boost Version %s.\\n" "${BVERSION}"
printf "\\tEOS.IO requires Boost version 1.67.\\n"
printf "\\tWould you like to uninstall version %s and install Boost version 1.67.\\n" "${BVERSION}"
select yn in "Yes" "No"; do
case $yn in
[Yy]* )
if "${BREW}" list | grep "boost"
then
printf "\\tUninstalling Boost Version %s.\\n" "${BVERSION}"
if ! "${BREW}" uninstall --force boost
then
printf "\\tUnable to remove boost libraries at this time. 0\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
else
printf "\\tRemoving Boost Version %s.\\n" "${BVERSION}"
if ! sudo rm -rf "/usr/local/include/boost"
then
printf "\\tUnable to remove boost libraries at this time. 1\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! sudo rm -rf /usr/local/lib/libboost*
then
printf "\\tUnable to remove boost libraries at this time. 2\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
fi
break;;
[Nn]* ) echo "User cancelled installation of Boost libraries, Exiting now."; exit;;
* ) echo "Please type 1 for yes or 2 for no.";;
esac
done
fi
printf "\\tInstalling boost libraries.\\n"
if ! "${BREW}" install https://raw.githubusercontent.com/Homebrew/homebrew-core/f946d12e295c8a27519b73cc810d06593270a07f/Formula/boost.rb
then
printf "\\tUnable to install boost 1.67 libraries at this time. 0\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if [ -d "$BUILD_DIR" ]; then
if ! rm -rf "$BUILD_DIR"
then
printf "\\tUnable to remove directory %s. Please remove this directory and run this script %s again. 0\\n" "$BUILD_DIR" "${BASH_SOURCE[0]}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
fi
printf "\\tBoost 1.67.0 successfully installed @ /usr/local.\\n"
else
printf "\\tBoost 1.67.0 found at /usr/local.\\n"
fi
printf "\\n\\tChecking MongoDB C++ driver installation.\\n"
MONGO_INSTALL=true
if [ -e "/usr/local/lib/libmongocxx-static.a" ]; then
MONGO_INSTALL=false
if ! version=$( grep "Version:" /usr/local/lib/pkgconfig/libmongocxx-static.pc | tr -s ' ' | awk '{print $2}' )
then
printf "\\tUnable to determine mongodb-cxx-driver version.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
maj=$( echo "${version}" | cut -d'.' -f1 )
min=$( echo "${version}" | cut -d'.' -f2 )
if [ "${maj}" -gt 3 ]; then
MONGO_INSTALL=true
elif [ "${maj}" -eq 3 ] && [ "${min}" -lt 3 ]; then
MONGO_INSTALL=true
fi
fi
if [ $MONGO_INSTALL == "true" ]; then
if ! cd "${TEMP_DIR}"
then
printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! pkgconfig=$( "${BREW}" list | grep pkg-config )
then
if ! "${BREW}" install --force pkg-config
then
printf "\\tHomebrew returned an error installing pkg-config.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! "${BREW}" unlink pkg-config && "${BREW}" link --force pkg-config
then
printf "\\tHomebrew returned an error linking pkgconfig.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
fi
STATUS=$( curl -LO -w '%{http_code}' --connect-timeout 30 https://github.com/mongodb/mongo-c-driver/releases/download/1.10.2/mongo-c-driver-1.10.2.tar.gz )
if [ "${STATUS}" -ne 200 ]; then
if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.10.2.tar.gz"
then
printf "\\tUnable to remove file %s/mongo-c-driver-1.10.2.tar.gz.\\n" "${TEMP_DIR}"
fi
printf "\\tUnable to download MongoDB C driver at this time.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! tar xf mongo-c-driver-1.10.2.tar.gz
then
printf "\\tUnable to unarchive file %s/mongo-c-driver-1.10.2.tar.gz.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.10.2.tar.gz"
then
printf "\\tUnable to remove file mongo-c-driver-1.10.2.tar.gz.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd "${TEMP_DIR}"/mongo-c-driver-1.10.2
then
printf "\\tUnable to cd into directory %s/mongo-c-driver-1.10.2.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! mkdir cmake-build
then
printf "\\tUnable to create directory %s/mongo-c-driver-1.10.2/cmake-build.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd cmake-build
then
printf "\\tUnable to enter directory %s/mongo-c-driver-1.10.2/cmake-build.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BSON=ON \
-DENABLE_SSL=DARWIN -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON ..
then
printf "\\tConfiguring MongoDB C driver has encountered the errors above.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! make -j"${CPU_CORE}"
then
printf "\\tError compiling MongoDB C driver.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! sudo make install
then
printf "\\tError installing MongoDB C driver.\\nMake sure you have sudo privileges.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd "${TEMP_DIR}"
then
printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! rm -rf "${TEMP_DIR}/mongo-c-driver-1.10.2"
then
printf "\\tUnable to remove directory %s/mongo-c-driver-1.10.2.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/v3.3 --depth 1
then
printf "\\tUnable to clone MongoDB C++ driver at this time.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd "${TEMP_DIR}/mongo-cxx-driver/build"
then
printf "\\tUnable to enter directory %s/mongo-cxx-driver/build.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
then
printf "\\tCmake has encountered the above errors building the MongoDB C++ driver.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! make -j"${CPU_CORE}"
then
printf "\\tError compiling MongoDB C++ driver.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! sudo make install
then
printf "\\tError installing MongoDB C++ driver.\\nMake sure you have sudo privileges.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd "${TEMP_DIR}"
then
printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! rm -rf "${TEMP_DIR}/mongo-cxx-driver"
then
printf "\\tUnable to remove directory %s/mongo-cxx-driver.\\n" "${TEMP_DIR}" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
printf "\\tMongo C++ driver installed at /usr/local/lib/libmongocxx-static.a.\\n"
else
printf "\\tMongo C++ driver found at /usr/local/lib/libmongocxx-static.a.\\n"
fi
printf "\\n\\tChecking secp256k1-zkp installation.\\n"
# install secp256k1-zkp (Cryptonomex branch)
if [ ! -e "/usr/local/lib/libsecp256k1.a" ]; then
if ! cd "${TEMP_DIR}"
then
printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! git clone https://github.com/cryptonomex/secp256k1-zkp.git
then
printf "\\tUnable to clone repo secp256k1-zkp @ https://github.com/cryptonomex/secp256k1-zkp.git.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd "${TEMP_DIR}/secp256k1-zkp"
then
printf "\\tUnable to enter directory %s/secp256k1-zkp.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! ./autogen.sh
then
printf "\\tError running autogen.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! ./configure
then
printf "\\tConfiguring secp256k1-zkp has returned the above error.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! make -j"${CPU_CORE}"
then
printf "\\tError compiling secp256k1-zkp.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! sudo make install
then
printf "\\tInstalling secp256k1-zkp has returned the above error.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! rm -rf "${TEMP_DIR}/secp256k1-zkp"
then
printf "\\tUnable to remove directory %s/secp256k1-zkp56k1-zkp.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
printf "\\n\\n\\tSuccessffully installed secp256k1 @ /usr/local/lib/.\\n\\n"
else
printf "\\tsecp256k1 found at /usr/local/lib/.\\n"
fi
printf "\\n\\tChecking LLVM with WASM support.\\n"
if [ ! -d /usr/local/wasm/bin ]; then
if ! cd "${TEMP_DIR}"
then
printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! mkdir "${TEMP_DIR}/wasm-compiler"
then
printf "\\tUnable to create directory %s/wasm-compiler.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd "${TEMP_DIR}/wasm-compiler"
then
printf "\\tUnable to enter directory %s/wasm-compiler.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git
then
printf "\\tUnable to clone llvm repo @ https://github.com/llvm-mirror/llvm.git.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd "${TEMP_DIR}/wasm-compiler/llvm/tools"
then
printf "\\tUnable to enter directory %s/wasm-compiler/llvm/tools.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git
then
printf "\\tUnable to clone clang repo @ https://github.com/llvm-mirror/clang.git.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd "${TEMP_DIR}/wasm-compiler/llvm"
then
printf "\\tUnable to enter directory %s/wasm-compiler/llvm.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! mkdir "${TEMP_DIR}/wasm-compiler/llvm/build"
then
printf "\\tUnable to create directory %s/wasm-compiler/llvm/build.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd "${TEMP_DIR}/wasm-compiler/llvm/build"
then
printf "\\tUnable to enter directory %s/wasm-compiler/llvm/build.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr/local/wasm \
-DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly \
-DCMAKE_BUILD_TYPE=Release ../
then
printf "\\tError compiling LLVM/Clang with WASM support.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! sudo make -j"${CPU_CORE}" install
then
printf "\\tCompiling LLVM/Clang with WASM support has exited with the error above.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! sudo rm -rf "${TEMP_DIR}/wasm-compiler"
then
printf "\\tUnable to remove directory %s/wasm-compiler.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
printf "\\tSuccessfully installed LLVM/Clang with WASM support @ /usr/local/wasm/bin/.\\n"
else
printf "\\tWASM found at /usr/local/wasm/bin/.\\n"
fi
function print_instructions()
{
printf "\\n\\t%s -f %s &\\n" "$( command -v mongod )" "${MONGOD_CONF}"
printf "\\tcd %s; make test\\n\\n" "${BUILD_DIR}"
return 0
}