-
Notifications
You must be signed in to change notification settings - Fork 55
/
build.sh
executable file
·158 lines (141 loc) · 2.99 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2022 Intel Corporation
set -e
user=$(whoami)
function usage() {
echo "Usage: $0 [debug/debugoptimized/plain/release]"
exit 0
}
buildtype=release
enable_asan=false
enable_tap=false
enable_usdt=true
if [ -n "$MTL_BUILD_ENABLE_ASAN" ]; then
if [ "$MTL_BUILD_ENABLE_ASAN" == "true" ]; then
enable_asan=true
buildtype=debug # use debug build as default for asan
echo "Enable asan check."
fi
fi
if [ -n "$MTL_BUILD_ENABLE_TAP" ]; then
if [ "$MTL_BUILD_ENABLE_TAP" == "true" ]; then
enable_tap=true
echo "Enable tap"
fi
fi
if [ -n "$MTL_BUILD_DISABLE_USDT" ]; then
if [ "$MTL_BUILD_DISABLE_USDT" == "true" ]; then
enable_usdt=false
echo "Disable USDT"
fi
fi
if [ -n "$1" ]; then
case $1 in
"debug")
buildtype=debug
enable_asan=true
;;
"debugonly")
buildtype=debug
;;
"debugoptimized")
buildtype=debugoptimized
;;
"plain")
buildtype=plain
;;
"release")
buildtype=release
;;
*)
usage
;;
esac
fi
WORKSPACE=$PWD
LIB_BUILD_DIR=${WORKSPACE}/build
APP_BUILD_DIR=${WORKSPACE}/build/app
TEST_BUILD_DIR=${WORKSPACE}/build/tests
PLUGINS_BUILD_DIR=${WORKSPACE}/build/plugins
LD_PRELOAD_BUILD_DIR=${WORKSPACE}/build/ld_preload
MANAGER_BUILD_DIR=${WORKSPACE}/build/manager
RDMA_BUILD_DIR=${WORKSPACE}/build/rdma
# build lib
meson setup "${LIB_BUILD_DIR}" -Dbuildtype="$buildtype" -Denable_asan="$enable_asan" -Denable_tap="$enable_tap" -Denable_usdt="$enable_usdt"
pushd "${LIB_BUILD_DIR}"
ninja
if [ "$user" == "root" ] || [ "$OS" == "Windows_NT" ]; then
ninja install
else
sudo ninja install
fi
popd
# build rdma lib
if [ "$OS" != "Windows_NT" ]; then
pushd rdma/
meson setup "${RDMA_BUILD_DIR}" -Dbuildtype="$buildtype" -Denable_asan="$enable_asan"
popd
pushd "${RDMA_BUILD_DIR}"
ninja
if [ "$user" == "root" ]; then
ninja install
else
sudo ninja install
fi
popd
fi
# build app
pushd app/
meson setup "${APP_BUILD_DIR}" -Dbuildtype="$buildtype" -Denable_asan="$enable_asan"
popd
pushd "${APP_BUILD_DIR}"
ninja
popd
# build tests
pushd tests/
meson setup "${TEST_BUILD_DIR}" -Dbuildtype="$buildtype" -Denable_asan="$enable_asan"
popd
pushd "${TEST_BUILD_DIR}"
ninja
popd
# build plugins
pushd plugins/
meson setup "${PLUGINS_BUILD_DIR}" -Dbuildtype="$buildtype" -Denable_asan="$enable_asan"
popd
pushd "${PLUGINS_BUILD_DIR}"
ninja
if [ "$user" == "root" ] || [ "$OS" == "Windows_NT" ]; then
ninja install
else
sudo ninja install
fi
popd
# build ld_preload
if [ "$OS" != "Windows_NT" ]; then
pushd ld_preload/
meson setup "${LD_PRELOAD_BUILD_DIR}" -Dbuildtype="$buildtype" -Denable_asan="$enable_asan"
popd
pushd "${LD_PRELOAD_BUILD_DIR}"
ninja
if [ "$user" == "root" ]; then
ninja install
else
sudo ninja install
fi
popd
fi
# build mtl_manager
if [ "$OS" != "Windows_NT" ]; then
pushd manager/
meson setup "${MANAGER_BUILD_DIR}" -Dbuildtype="$buildtype" -Denable_asan="$enable_asan"
popd
pushd "${MANAGER_BUILD_DIR}"
ninja
if [ "$user" == "root" ]; then
ninja install
else
sudo ninja install
fi
popd
fi