forked from OpenVisualCloud/Media-Transport-Library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·133 lines (117 loc) · 2.67 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
#!/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
disable_pcapng=false
enable_asan=false
enable_kni=false
enable_tap=false
if [ -n "$MTL_BUILD_DISABLE_PCAPNG" ]; then
if [ "$MTL_BUILD_DISABLE_PCAPNG" == "true" ]; then
disable_pcapng=true
echo "Disable pcapng function."
fi
fi
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_KNI" ]; then
if [ "$MTL_BUILD_ENABLE_KNI" == "true" ]; then
enable_kni=true
echo "Enable kni"
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 "$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
# build lib
meson "${LIB_BUILD_DIR}" -Dbuildtype="$buildtype" -Ddisable_pcapng="$disable_pcapng" -Denable_asan="$enable_asan" -Denable_kni="$enable_kni" -Denable_tap="$enable_tap"
pushd "${LIB_BUILD_DIR}"
ninja
if [ "$user" == "root" ]; then
ninja install
else
sudo ninja install
fi
popd
# build app
pushd app/
meson "${APP_BUILD_DIR}" -Dbuildtype="$buildtype" -Denable_asan="$enable_asan"
popd
pushd "${APP_BUILD_DIR}"
ninja
popd
# build tests
pushd tests/
meson "${TEST_BUILD_DIR}" -Dbuildtype="$buildtype" -Denable_asan="$enable_asan"
popd
pushd "${TEST_BUILD_DIR}"
ninja
popd
# build plugins
pushd plugins/
meson "${PLUGINS_BUILD_DIR}" -Dbuildtype="$buildtype" -Denable_asan="$enable_asan"
popd
pushd "${PLUGINS_BUILD_DIR}"
ninja
if [ "$user" == "root" ]; then
ninja install
else
sudo ninja install
fi
popd
# build ld_preload
pushd ld_preload/
meson "${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