-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder
executable file
·94 lines (77 loc) · 2.22 KB
/
builder
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
#!/bin/bash
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
installdir=/usr/local/bin
# basically run it like this
# ./builder clean
# ./builder init release
# ./builder build release 6
# clean any previous builkd output
# ./builder clean
# initialize the build (install deps, run cmake etc)
# ./builder init <release>
# where <release> is either 'debug' or 'release'
# build nerva
# ./builder build <release> <threads>
# where <release> is either 'debug' or 'release'
# Where <threads> is the number of threads to use with make
function checkdistro()
{
if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
local os_distro="unknown"
local os_ver="unknown"
if [ -f /etc/os-release ]; then
source /etc/os-release
os_distro=$ID
os_ver=$VERSION_ID
elif [ -f /etc/lsb-release ]; then
source /etc/lsb-release
os_distro=$DISTRIB_ID
os_ver=$DISTRIB_RELEASE
fi
export NERVA_BUILD_DISTRO=${os_distro}
export NERVA_BUILD_DISTRO_VERSION=${os_ver}
fi
}
function install()
{
sudo cp ${dir}/build/bin/nerva* ${installdir}
}
function uninstall()
{
sudo rm ${installdir}/nerva*
}
function clean()
{
cd ${dir}
rm -rf ${dir}/build
find -name CMakeCache.txt | xargs rm
find -name CMakeFiles | xargs rm -rf
find -name *.a | xargs rm
find -name *.o | xargs rm
find -name *.so | xargs rm
}
function init()
{
checkdistro
if [ $NERVA_BUILD_DISTRO == "ubuntu" ] || [ $NERVA_BUILD_DISTRO == "debian" ]; then
sudo apt install -y \
git build-essential cmake pkg-config libboost-all-dev libssl-dev libzmq3-dev libunbound-dev libsodium-dev \
libminiupnpc-dev libunwind8-dev liblzma-dev libreadline6-dev libldns-dev libexpat1-dev libgtest-dev doxygen graphviz
elif [ $NERVA_BUILD_DISTRO == "fedora" ]; then
sudo dnf install -y \
git make automake cmake gcc-c++ boost-devel miniupnpc-devel graphviz \
doxygen unbound-devel libunwind-devel pkgconfig cppzmq-devel openssl-devel libcurl-devel --setopt=install_weak_deps=False
else
echo "Cannot install dependencies on your system. This distro is not officially supported"
exit 1
fi
mkdir -p ${dir}/build/$1
cd ${dir}/build/$1
cmake -D CMAKE_BUILD_TYPE=$1 -D BUILD_SHARED_LIBS=OFF ../..
}
function build()
{
cd ${dir}/build/$1
make -j $2
}
$1 $2 $3