Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
248 changes: 144 additions & 104 deletions eosio_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,60 +30,109 @@
# https://github.com/EOSIO/eos/blob/master/LICENSE.txt
##########################################################################

VERSION=1.2
ULIMIT=$( ulimit -u )
WORK_DIR=$PWD
BUILD_DIR=${WORK_DIR}/build
TEMP_DIR=/tmp
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "${CWD}" != "${PWD}" ]; then
printf "\\n\\tPlease cd into directory %s to run this script.\\n \\tExiting now.\\n\\n" "${CWD}"
exit 1
fi

function usage()
{
printf "\\tUsage: %s [Build Option -o <Debug|Release|RelWithDebInfo|MinSizeRel>] [CodeCoverage -c ] [Doxygen -d]\\n\\n" "$0" 1>&2
exit 1
}

ARCH=$( uname )
BUILD_DIR="${PWD}/build"
CMAKE_BUILD_TYPE=Release
DISK_MIN=20
DOXYGEN=false
ENABLE_COVERAGE_TESTING=false
TEMP_DIR="/tmp"
TIME_BEGIN=$( date -u +%s )
DOXYGEN=false #set to true to build docs
VERSION=1.2

txtbld=$(tput bold)
bldred=${txtbld}$(tput setaf 1)
txtrst=$(tput sgr0)

if [ $# -ne 0 ]; then
while getopts ":cdo:" opt; do
case "${opt}" in
o )
options=( "Debug" "Release" "RelWithDebInfo" "MinSizeRel" )
if [[ "${options[*]}" =~ "${OPTARG}" ]]; then
CMAKE_BUILD_TYPE="${OPTARG}"
else
printf "\\n\\tInvalid argument: %s\\n" "${OPTARG}" 1>&2
usage
exit 1
fi
;;
c )
ENABLE_COVERAGE_TESTING=true
;;
d )
DOXYGEN=true
;;
\? )
printf "\\n\\tInvalid Option: %s\\n" "-${OPTARG}" 1>&2
usage
exit 1
;;
: )
printf "\\n\\tInvalid Option: %s requires an argument.\\n" "-${OPTARG}" 1>&2
usage
exit 1
;;
* )
usage
exit 1
;;
esac
done
fi

if [ ! -d .git ]; then
printf "\n\tThis build script only works with sources cloned from git\n"
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"
printf "\\n\\tThis build script only works with sources cloned from git\\n"
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

STALE_SUBMODS=$(( `git submodule status | grep -c "^[+\-]"` ))
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"
printf "\\n\\tgit submodules are not up to date.\\n"
printf "\\tPlease run the command 'git submodule update --init --recursive'.\\n"
exit 1
fi

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

if [ $ARCH == "Linux" ]; then
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"
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
case "$OS_NAME" in
"Amazon Linux AMI")
FILE=${WORK_DIR}/scripts/eosio_build_amazon.sh
FILE="${PWD}/scripts/eosio_build_amazon.sh"
CXX_COMPILER=g++
C_COMPILER=gcc
MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
Expand All @@ -92,7 +141,7 @@
export PATH=${HOME}/opt/mongodb/bin:$PATH
;;
"CentOS Linux")
FILE=${WORK_DIR}/scripts/eosio_build_centos.sh
FILE="${PWD}/scripts/eosio_build_centos.sh"
CXX_COMPILER=g++
C_COMPILER=gcc
MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
Expand All @@ -101,99 +150,93 @@
export PATH=${HOME}/opt/mongodb/bin:$PATH
;;
"elementary OS")
FILE=${WORK_DIR}/scripts/eosio_build_ubuntu.sh
FILE="${PWD}/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
;;
"Fedora")
FILE=${WORK_DIR}/scripts/eosio_build_fedora.sh
FILE="${PWD}/scripts/eosio_build_fedora.sh"
CXX_COMPILER=g++
C_COMPILER=gcc
MONGOD_CONF=/etc/mongod.conf
export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm
;;
"Linux Mint")
FILE=${WORK_DIR}/scripts/eosio_build_ubuntu.sh
FILE="${PWD}/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
;;
"Ubuntu")
FILE=${WORK_DIR}/scripts/eosio_build_ubuntu.sh
FILE="${PWD}/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
;;
*)
printf "\n\tUnsupported Linux Distribution. Exiting now.\n\n"
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 WASM_ROOT=${HOME}/opt/wasm
export BOOST_ROOT="${HOME}/opt/boost_1_66_0"
OPENSSL_ROOT_DIR=/usr/include/openssl
WASM_ROOT="${HOME}/opt/wasm"
fi

if [ $ARCH == "Darwin" ]; then
FILE=${WORK_DIR}/scripts/eosio_build_darwin.sh
if [ "$ARCH" == "Darwin" ]; then
FILE="${PWD}/scripts/eosio_build_darwin.sh"
CXX_COMPILER=clang++
C_COMPILER=clang
MONGOD_CONF=/usr/local/etc/mongod.conf
OPENSSL_ROOT_DIR=/usr/local/opt/openssl
export WASM_ROOT=/usr/local/wasm
WASM_ROOT=/usr/local/wasm
fi

. $FILE

printf "\n\n>>>>>>>> ALL dependencies sucessfully found or installed . Installing EOS.IO\n\n"
. "$FILE"

COMPILE_EOS=1
COMPILE_CONTRACTS=1
printf "\\n\\n>>>>>>>> ALL dependencies sucessfully found or installed . Installing EOS.IO\\n\\n"
printf ">>>>>>>> CMAKE_BUILD_TYPE=%s\\n" "${CMAKE_BUILD_TYPE}"
printf ">>>>>>>> ENABLE_COVERAGE_TESTING=%s\\n" "${ENABLE_COVERAGE_TESTING}"
printf ">>>>>>>> DOXYGEN=%s\\n\\n" "${DOXYGEN}"

# export EOS_BUILD_TYPE=[Debug|Release|RelWithDebInfo|MinSizeRel|CodeCoverage] to enable
CMAKE_BUILD_TYPE=Release
CODE_COVERAGE_OPTS=
export ENABLE_CODE_COVERAGE=false
if [ ! -z $EOS_BUILD_TYPE ]; then
if [[ $EOS_BUILD_TYPE == "CodeCoverage" ]]; then
ENABLE_CODE_COVERAGE=true
EOS_BUILD_TYPE=Debug
fi

CMAKE_BUILD_TYPE=$EOS_BUILD_TYPE
if [ ! -d "${BUILD_DIR}" ]; then
if ! mkdir -p "${BUILD_DIR}"
then
printf "Unable to create build directory %s.\\n Exiting now.\\n" "${BUILD_DIR}"
exit 1;
fi
fi

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

if [ -z $CMAKE ]; then
CMAKE=$( which cmake )

if ! cd "${BUILD_DIR}"
then
printf "Unable to enter build directory %s.\\n Exiting now.\\n" "${BUILD_DIR}"
exit 1;
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=true \
-DENABLE_COVERAGE_TESTING=${ENABLE_CODE_COVERAGE} -DBUILD_DOXYGEN=${DOXYGEN} \
..
if [ -z "$CMAKE" ]; then
CMAKE=$( command -v cmake )
fi

if [ $? -ne 0 ]; then
printf "\n\t>>>>>>>>>>>>>>>>>>>> CMAKE building EOSIO has exited with the above error.\n\n"
if ! "${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=true \
-DENABLE_COVERAGE_TESTING="${ENABLE_COVERAGE_TESTING}" -DBUILD_DOXYGEN="${DOXYGEN}" ..
then
printf "\\n\\t>>>>>>>>>>>>>>>>>>>> CMAKE building EOSIO has exited with the above error.\\n\\n"
exit -1
fi

make -j${CPU_CORE}

if [ $? -ne 0 ]; then
printf "\n\t>>>>>>>>>>>>>>>>>>>> MAKE building EOSIO has exited with the above error.\n\n"
if ! make -j"${CPU_CORE}"
then
printf "\\n\\t>>>>>>>>>>>>>>>>>>>> MAKE building EOSIO has exited with the above error.\\n\\n"
exit -1
fi

TIME_END=$(( `date -u +%s` - $TIME_BEGIN ))
TIME_END=$(( $(date -u +%s) - ${TIME_BEGIN} ))

printf "\n\n${bldred}\t _______ _______ _______ _________ _______\n"
printf '\t( ____ \( ___ )( ____ \\\\__ __/( ___ )\n'
Expand All @@ -204,35 +247,32 @@
printf "\t| (____/\| (___) |/\____) |___) (___| (___) |\n"
printf "\t(_______/(_______)\_______)\_______/(_______)\n${txtrst}"

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

print_instructions

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

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} \
-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
if [ "x${EOSIO_BUILD_PACKAGE}" != "x" ]; then
# Build eos.io package
if ! "$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}" -DCMAKE_INSTALL_PREFIX="/usr" ..
then
printf "\\n\\t>>>>>>>>>>>>>>>>>>>> CMAKE building eos.io package has exited with the above error.\\n\\n"
exit -1
fi

if ! make -j${CPU_CORE} VERBOSE=0 package
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
Loading