-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlinux_deploy.sh
More file actions
executable file
·111 lines (92 loc) · 2.22 KB
/
linux_deploy.sh
File metadata and controls
executable file
·111 lines (92 loc) · 2.22 KB
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
#!/bin/bash
set -e
build_dir="build"
release_flags="-DCMAKE_BUILD_TYPE=Release"
opt_flags="-O3 -march=native -flto -funroll-loops -fomit-frame-pointer -fstrict-aliasing -ftree-vectorize -fvisibility=hidden"
nproc=$(nproc)
install_dependency() {
sudo apt-get update
sudo apt-get install -y git cmake \
clang sqlite3
}
function check() {
if ! command -v "$1" >/dev/null 2>&1; then
echo "[ERR] Could not find $1 in your system. Aborting"
exit 1
fi
}
function linter_check() {
local options=$1
if [[ $options == "clippy" ]]; then
local cargo="cargo"
local backend="src/back_end"
check "$cargo"
cd ..
cd "$backend" || exit 1
"$cargo" clippy \
--all-targets --all-features \
-- -D clippy::all -D clippy::pedantic \
-D clippy::nursery -D clippy::perf
else
local clang_tidy="clang-tidy"
check "$clang_tidy"
cd ..
clang-tidy src/**/*.cxx -p=build
fi
}
build_backend() {
local cargo="cargo"
local back_end="src/back_end"
check "$cargo"
check "rustup"
cd ..
cd "$back_end" || exit 1
"$cargo" build --release
}
backend_test() {
local cargo="cargo"
local back_end="src/back_end"
check "$cargo"
check "rustup"
cd ..
cd "$back_end" || exit 1
"$cargo" test
}
build_frontend() {
cd ..
if [ ! -d "$build_dir" ]; then
mkdir -p "$build_dir"
fi
cd "$build_dir" || exit
cmake -DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CXX_FLAGS="$opt_flags" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DRELEASE=ON \
-DLAZY_DEBUG=OFF \
"$release_flags" \
..
make -j "$nproc"
}
match_options() {
case "$1" in
"install-dependency") install_dependency ;;
"frontend-build") build_frontend ;;
"backend-build") build_backend ;;
"frontend-check") {
local clang_tidy="clang-tidy"
linter_check "$clang_tidy"
} ;;
"backend-check") {
local clippy="clippy"
linter_check "$clippy"
} ;;
"backend-test") {
backend_test
} ;;
*)
echo "Usage: $0 {install-dependency | frontend-build | backend-build}"
exit 1
esac
}
match_options "$1"