-
Notifications
You must be signed in to change notification settings - Fork 0
/
eosio_build.sh
executable file
·201 lines (173 loc) · 6.26 KB
/
eosio_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
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
#!/bin/bash
##########################################################################
# This is the EOSIO automated install script for Linux and Mac OS.
# This file was downloaded from https://github.com/EOSIO/eos
#
# Copyright (c) 2017, Respective Authors all rights reserved.
#
# After June 1, 2018 this software is available under the following terms:
#
# The MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# https://github.com/EOSIO/eos/blob/master/LICENSE.txt
##########################################################################
VERSION=1.1
ULIMIT=$( ulimit -u )
# Define directories.
WORK_DIR=$PWD
BUILD_DIR=${WORK_DIR}/build
TEMP_DIR=/tmp
ARCH=$(uname)
DISK_MIN=20
txtbld=$(tput bold)
bldred=${txtbld}$(tput setaf 1)
txtrst=$(tput sgr0)
printf "\n\tARCHITECTURE ${ARCH}\n"
if [ $ARCH == "Linux" ]; then
if [ ! -e /etc/os-release ]; then
printf "\n\tEOSIO currently supports Amazon, Centos, Fedora, Mint & Ubuntu Linux only.\n"
printf "\tPlease install on the latest version of one of these Linux distributions.\n"
printf "\thttps://aws.amazon.com/amazon-linux-ami/\n"
printf "\thttps://www.centos.org/\n"
printf "\thttps://start.fedoraproject.org/\n"
printf "\thttps://linuxmint.com/\n"
printf "\thttps://www.ubuntu.com/\n"
printf "\tExiting now.\n"
exit 1
fi
OS_NAME=$( cat /etc/os-release | grep ^NAME | cut -d'=' -f2 | sed 's/\"//gI' )
case $OS_NAME in
"Amazon Linux AMI")
FILE=${WORK_DIR}/scripts/eosio_build_amazon.sh
export CMAKE=${HOME}/opt/cmake/bin/cmake
CXX_COMPILER=g++
C_COMPILER=gcc
export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm
BUILD_MONGO_DB_PLUGIN=false
MONGOD_CONF=""
;;
"CentOS Linux")
FILE=${WORK_DIR}/scripts/eosio_build_centos.sh
export CMAKE=${HOME}/opt/cmake/bin/cmake
CXX_COMPILER=g++
C_COMPILER=gcc
export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm
BUILD_MONGO_DB_PLUGIN=false
MONGOD_CONF=""
;;
"Fedora")
FILE=${WORK_DIR}/scripts/eosio_build_fedora.sh
CXX_COMPILER=g++
C_COMPILER=gcc
export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm
BUILD_MONGO_DB_PLUGIN=true
MONGOD_CONF=/etc/mongod.conf
;;
"Linux Mint")
FILE=${WORK_DIR}/scripts/eosio_build_ubuntu.sh
CXX_COMPILER=clang++-4.0
C_COMPILER=clang-4.0
BUILD_MONGO_DB_PLUGIN=true
MONGOD_CONF=/etc/mongod.conf
;;
"Ubuntu")
FILE=${WORK_DIR}/scripts/eosio_build_ubuntu.sh
CXX_COMPILER=clang++-4.0
C_COMPILER=clang-4.0
BUILD_MONGO_DB_PLUGIN=true
MONGOD_CONF=/etc/mongod.conf
;;
*)
printf "\n\tUnsupported Linux Distribution. Exiting now.\n\n"
exit 1
esac
export BOOST_ROOT=${HOME}/opt/boost_1_66_0
export OPENSSL_ROOT_DIR=/usr/include/openssl
export OPENSSL_LIBRARIES=/usr/include/openssl
export WASM_ROOT=${HOME}/opt/wasm
. $FILE
fi
if [ $ARCH == "Darwin" ]; then
OPENSSL_ROOT_DIR=/usr/local/opt/openssl
OPENSSL_LIBRARIES=/usr/local/opt/openssl/lib
export WASM_ROOT=/usr/local/wasm
CXX_COMPILER=clang++
C_COMPILER=clang
BUILD_MONGO_DB_PLUGIN=true
MONGOD_CONF=/usr/local/etc/mongod.conf
. scripts/eosio_build_darwin.sh
fi
printf "\n\n>>>>>>>> ALL dependencies sucessfully found or installed . Installing EOS.IO\n\n"
COMPILE_EOS=1
COMPILE_CONTRACTS=1
CMAKE_BUILD_TYPE=RelWithDebugInfo
cd ${WORK_DIR}
mkdir -p ${BUILD_DIR}
cd ${BUILD_DIR}
if [ -z $CMAKE ]; then
CMAKE=$( which cmake )
fi
$CMAKE -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_C_COMPILER=${C_COMPILER} -DWASM_ROOT=${WASM_ROOT} \
-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} -DBUILD_MONGO_DB_PLUGIN=${BUILD_MONGO_DB_PLUGIN} \
-DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES} ..
if [ $? -ne 0 ]; then
printf "\n\t>>>>>>>>>>>>>>>>>>>> CMAKE building EOSIO has exited with the above error.\n\n"
exit -1
fi
make -j${CPU_CORE} VERBOSE=0
if [ $? -ne 0 ]; then
printf "\n\t>>>>>>>>>>>>>>>>>>>> MAKE building EOSIO has exited with the above error.\n\n"
exit -1
fi
printf "\n\t>>>>>>>>>>>>>>>>>>>> EOSIO has been successfully built.\n\n"
if [ $BUILD_MONGO_DB_PLUGIN == true ]; then
printf "\n\tChecking if MongoDB is running.\n"
MONGODB_PID=$( pgrep -x mongod )
if [ -z $MONGODB_PID ]; then
printf "\n\tStarting MongoDB.\n"
sudo mongod -f ${MONGOD_CONF} &
if [ $? -ne 0 ]; then
printf "\n\tUnable to start MongoDB.\nExiting now.\n\n"
exit -1
fi
printf "\n\tSuccessfully started MongoDB.\n"
else
printf "\n\tMongoDB is running PID=${MONGODB_PID}.\n"
fi
fi
if [ "x${EOSIO_BUILD_PACKAGE}" != "x" ]; then
# Build eos.io package
$CMAKE -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_C_COMPILER=${C_COMPILER} -DWASM_ROOT=${WASM_ROOT} \
-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} -DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES} \
-DCMAKE_INSTALL_PREFIX=/usr ..
if [ $? -ne 0 ]; then
printf "\n\t>>>>>>>>>>>>>>>>>>>> CMAKE building eos.io package has exited with the above error.\n\n"
exit -1
fi
make -j${CPU_CORE} VERBOSE=0 package
if [ $? -ne 0 ]; then
printf "\n\t>>>>>>>>>>>>>>>>>>>> MAKE building eos.io package has exited with the above error.\n\n"
exit -1
fi
printf "\n\t>>>>>>>>>>>>>>>>>>>> eos.io package has been successfully built.\n\n"
fi