eosio_build.sh 8.1 KB
Newer Older
1 2
#!/bin/bash
##########################################################################
3
# This is the EOSIO automated install script for Linux and Mac OS.
4 5 6 7 8
# 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:
9
# 
10
# The MIT License
11
# 
12 13 14 15 16 17
# 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:
18
# 
19 20
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
21
# 
22 23 24 25 26 27 28 29 30 31
# 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
##########################################################################
32

33
	VERSION=1.2
34 35 36 37
	ULIMIT=$( ulimit -u )
	WORK_DIR=$PWD
	BUILD_DIR=${WORK_DIR}/build
	TEMP_DIR=/tmp
38
	ARCH=$( uname )
39
	DISK_MIN=20
40
	TIME_BEGIN=$( date -u +%s )
G
Greg Lee 已提交
41
	DOXYGEN=false #set to true to build docs
42

43
	txtbld=$(tput bold)
44 45 46
	bldred=${txtbld}$(tput setaf 1)
	txtrst=$(tput sgr0)

47
	if [ ! -d .git ]; then
48
		printf "\n\tThis build script only works with sources cloned from git\n"
49 50 51 52
		printf "\tPlease clone a new eos directory with 'git clone https://github.com/EOSIO/eos --recursive'\n"
		printf "\tSee the wiki for instructions: https://github.com/EOSIO/eos/wiki\n"
		exit 1
	fi
53

54 55 56 57 58 59 60
	STALE_SUBMODS=$(( `git submodule status | grep -c "^[+\-]"` ))
	if [ $STALE_SUBMODS -gt 0 ]; then
		printf "\ngit submodules are not up to date\n"
		printf "\tPlease run the command 'git submodule update --init --recursive'\n"
		exit 1
	fi

61 62
	printf "\n\tBeginning build version: ${VERSION}\n"
	printf "\t$( date -u )\n"
63
	printf "\tUser: $( whoami )\n"
64 65 66 67
	printf "\tgit head id: $( cat .git/refs/heads/master )\n"
	printf "\tCurrent branch: $( git branch | grep \* )\n"
	printf "\n\tARCHITECTURE: ${ARCH}\n"

68
	if [ $ARCH == "Linux" ]; then
69
		
70
		if [ ! -e /etc/os-release ]; then
71 72 73 74 75 76 77 78
			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"
79 80
			exit 1
		fi
81
	
82
		OS_NAME=$( cat /etc/os-release | grep ^NAME | cut -d'=' -f2 | sed 's/\"//gI' )
83
	
84
		case $OS_NAME in
85 86 87 88
			"Amazon Linux AMI")
				FILE=${WORK_DIR}/scripts/eosio_build_amazon.sh
				CXX_COMPILER=g++
				C_COMPILER=gcc
89
				MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
90 91
				export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm
				export CMAKE=${HOME}/opt/cmake/bin/cmake
92
				export PATH=${HOME}/opt/mongodb/bin:$PATH
93
			;;
94 95
			"CentOS Linux")
				FILE=${WORK_DIR}/scripts/eosio_build_centos.sh
96 97
				CXX_COMPILER=g++
				C_COMPILER=gcc
98
				MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
99 100
				export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm
				export CMAKE=${HOME}/opt/cmake/bin/cmake
101
				export PATH=${HOME}/opt/mongodb/bin:$PATH
102
			;;
B
Bill Hamilton 已提交
103 104 105 106 107 108 109
			"elementary OS")
				FILE=${WORK_DIR}/scripts/eosio_build_ubuntu.sh
				CXX_COMPILER=clang++-4.0
				C_COMPILER=clang-4.0
				MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
				export PATH=${HOME}/opt/mongodb/bin:$PATH
			;;
110 111
			"Fedora")
				FILE=${WORK_DIR}/scripts/eosio_build_fedora.sh
112 113
				CXX_COMPILER=g++
				C_COMPILER=gcc
114
				MONGOD_CONF=/etc/mongod.conf
115
				export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm
116 117 118 119 120
			;;
			"Linux Mint")
				FILE=${WORK_DIR}/scripts/eosio_build_ubuntu.sh
				CXX_COMPILER=clang++-4.0
				C_COMPILER=clang-4.0
121 122
				MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
				export PATH=${HOME}/opt/mongodb/bin:$PATH
123
			;;
124 125 126 127
			"Ubuntu")
				FILE=${WORK_DIR}/scripts/eosio_build_ubuntu.sh
				CXX_COMPILER=clang++-4.0
				C_COMPILER=clang-4.0
128 129
				MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
				export PATH=${HOME}/opt/mongodb/bin:$PATH
130
			;;
131 132 133 134
			*)
				printf "\n\tUnsupported Linux Distribution. Exiting now.\n\n"
				exit 1
		esac
B
basarrcan 已提交
135

136 137
		export BOOST_ROOT=${HOME}/opt/boost_1_66_0
		export OPENSSL_ROOT_DIR=/usr/include/openssl
138
		export WASM_ROOT=${HOME}/opt/wasm
139 140 141
	fi

	if [ $ARCH == "Darwin" ]; then
142
		FILE=${WORK_DIR}/scripts/eosio_build_darwin.sh
143 144
		CXX_COMPILER=clang++
		C_COMPILER=clang
145
		export BOOST_ROOT=/usr/local
146
		MONGOD_CONF=/usr/local/etc/mongod.conf
147 148
		OPENSSL_ROOT_DIR=/usr/local/opt/openssl
		export WASM_ROOT=/usr/local/wasm
149 150
	fi

151 152
	. $FILE

153 154 155 156
	printf "\n\n>>>>>>>> ALL dependencies sucessfully found or installed . Installing EOS.IO\n\n"

	COMPILE_EOS=1
	COMPILE_CONTRACTS=1
157

158
# 	export EOS_BUILD_TYPE=[Debug|Release|RelWithDebInfo|MinSizeRel|CodeCoverage] to enable
159
	CMAKE_BUILD_TYPE=Release
160 161
	CODE_COVERAGE_OPTS=
	export ENABLE_CODE_COVERAGE=false
162
	if [ ! -z $EOS_BUILD_TYPE ]; then
163 164 165 166 167 168
            if [[ $EOS_BUILD_TYPE == "CodeCoverage" ]]; then
                ENABLE_CODE_COVERAGE=true
                EOS_BUILD_TYPE=Debug
            fi

	    CMAKE_BUILD_TYPE=$EOS_BUILD_TYPE
169
	fi
170 171 172 173 174

	cd ${WORK_DIR}
	mkdir -p ${BUILD_DIR}
	cd ${BUILD_DIR}

175 176 177
	if [ -z $CMAKE ]; then
		CMAKE=$( which cmake )
	fi
178
	
179
	$CMAKE -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
180
	-DCMAKE_C_COMPILER=${C_COMPILER} -DWASM_ROOT=${WASM_ROOT} \
181
	-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} -DBUILD_MONGO_DB_PLUGIN=true \
182
	-DENABLE_COVERAGE_TESTING=${ENABLE_CODE_COVERAGE} -DBUILD_DOXYGEN=${DOXYGEN} \
183
	..
184
	
185 186
	if [ $? -ne 0 ]; then
		printf "\n\t>>>>>>>>>>>>>>>>>>>> CMAKE building EOSIO has exited with the above error.\n\n"
187 188 189
		exit -1
	fi

190
	make -j${CPU_CORE}
191 192 193 194 195

	if [ $? -ne 0 ]; then
		printf "\n\t>>>>>>>>>>>>>>>>>>>> MAKE building EOSIO has exited with the above error.\n\n"
		exit -1
	fi
196 197 198
	
	TIME_END=$(( `date -u +%s` - $TIME_BEGIN ))

199
	printf "\n\n${bldred}\t _______  _______  _______ _________ _______\n"
200
	printf '\t(  ____ \(  ___  )(  ____ \\\\__   __/(  ___  )\n'
201 202 203 204 205
	printf "\t| (    \/| (   ) || (    \/   ) (   | (   ) |\n"
	printf "\t| (__    | |   | || (_____    | |   | |   | |\n"
	printf "\t|  __)   | |   | |(_____  )   | |   | |   | |\n"
	printf "\t| (      | |   | |      ) |   | |   | |   | |\n"
	printf "\t| (____/\| (___) |/\____) |___) (___| (___) |\n"
206
	printf "\t(_______/(_______)\_______)\_______/(_______)\n${txtrst}"
207 208 209

	printf "\n\tEOS.IO has been successfully built. %d:%d:%d\n\n" $(($TIME_END/3600)) $(($TIME_END%3600/60)) $(($TIME_END%60))
	printf "\tTo verify your installation run the following commands:\n"
210 211 212
	
	print_instructions

213 214 215 216 217
	printf "\tFor more information:\n"
	printf "\tEOS.IO website: https://eos.io\n"
	printf "\tEOS.IO Telegram channel @ https://t.me/EOSProject\n"
	printf "\tEOS.IO resources: https://eos.io/resources/\n"
	printf "\tEOS.IO wiki: https://github.com/EOSIO/eos/wiki\n\n\n"
218
				
219
   if [ "x${EOSIO_BUILD_PACKAGE}" != "x" ]; then
J
Jonathan Giszczak 已提交
220 221 222
      # 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} \
223
      -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} \
J
Jonathan Giszczak 已提交
224 225 226 227 228 229 230
      -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

231
      make -j${CPU_CORE} VERBOSE=0 package
J
Jonathan Giszczak 已提交
232 233 234 235 236 237 238

      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"
239
   fi