-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathbuild.sh
executable file
·134 lines (109 loc) · 2.31 KB
/
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
#!/bin/bash
# Copyright 2018 SMF Authors
#
set -e
set -x
if [[ -n ${CI} ]]; then
echo "In continous integration system..."
# disable colors so we can parse travis better
export GCC_COLORS=""
set -x
fi
this_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
rootdir="$(cd "${this_dir}"/.. && pwd)"
build_rootdir=${rootdir}/build
builddir=""
# shellcheck disable=SC1091
source /etc/os-release
function buildcmd() {
ninja -v -C "${1}"
}
case $ID in
debian|ubuntu|linuxmint)
echo "$ID supported"
;;
centos|fedora)
echo "$ID supported"
;;
*)
echo "$ID not supported"
exit 1
;;
esac
function debug {
echo "Debug"
builddir="${build_rootdir}/debug"
mkdir -p "$builddir"
cd "${rootdir}"
cmake -B"${builddir}" -GNinja \
-DSMF_MANAGE_DEPS=ON \
-DCMAKE_BUILD_TYPE=Debug -H"${rootdir}"
# for fmt.py
ln -sfn "${builddir}/compile_commands.json" "${rootdir}/compile_commands.json"
buildcmd "${builddir}"
}
function tests {
echo "Testing"
cd "${builddir}"
ctest --output-on-failure -V -R smf
}
function release {
echo "Release"
builddir="${build_rootdir}/release"
mkdir -p "$builddir"
cd "${rootdir}"
cmake -B"${builddir}" -GNinja \
-DSMF_MANAGE_DEPS=ON \
-DSMF_ENABLE_BENCHMARK_TESTS=ON \
-DCMAKE_BUILD_TYPE=Release -H"${rootdir}"
# for fmt.py
ln -sfn "${builddir}/compile_commands.json" "${rootdir}/compile_commands.json"
buildcmd "${builddir}"
}
function format {
echo "Format"
cd "${rootdir}"
"${rootdir}"/tools/fmt.py
}
function usage {
cat <<EOM
Usage: $(basename "$0") [OPTION]...
-d debug build
-r release build
-t run tests
-f format code
-h display help
EOM
exit 1
}
# run these after builds
do_tests=""
do_format=""
while getopts ":drtfpb" optKey; do
case $optKey in
d)
debug
;;
r)
release
;;
t)
do_tests=true
;;
f)
do_format=true
;;
*)
usage
;;
esac
done
if [ "${do_tests}" = "true" ]; then
tests
fi
if [ "${do_format}" = "true" ]; then
format
fi
if [ "${do_package}" = "true" ]; then
package
fi