forked from TokTok/qTox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-qtox-linux.sh
executable file
·149 lines (133 loc) · 2.97 KB
/
build-qtox-linux.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
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright © 2021 by The qTox Project Contributors
# Copyright © 2024-2025 The TokTok team
set -euo pipefail
usage() {
echo "$0 [--minimal|--full] --build-type [Debug|Release] [--with-gui-tests] [--sanitize] [--tidy]"
echo "Build script to build/test qtox from a CI environment."
echo "--minimal or --full are required, --build-type is required."
echo "UndefinedBehaviorSanitizer is always enabled. In Release builds, it is used without additional runtime dependencies."
}
while (($# > 0)); do
case $1 in
--minimal)
MINIMAL=1
shift
;;
--full)
MINIMAL=0
shift
;;
--sanitize)
SANITIZE=1
shift
;;
--tidy)
TIDY=1
shift
;;
--tidy-fix)
TIDY_FIX=1
shift
;;
--build-type)
BUILD_TYPE="$2"
shift 2
;;
--with-gui-tests)
GUI_TESTS=1
shift
;;
--help | -h)
usage
exit 1
;;
*)
echo "Unexpected argument $1"
usage
exit 1
;;
esac
done
if [ -z "${MINIMAL+x}" ]; then
echo "Please build either minimal or full version of qtox"
usage
exit 1
fi
if [ -z "${BUILD_TYPE+x}" ]; then
echo "Please specify build type"
usage
exit 1
fi
CMAKE_ARGS=()
if [ ! -z "${SANITIZE+x}" ]; then
CMAKE_ARGS+=("-DASAN=ON")
fi
if [ ! -z "${GUI_TESTS+x}" ]; then
CMAKE_ARGS+=("-DGUI_TESTS=ON")
fi
if [ "$BUILD_TYPE" = "Debug" ]; then
CMAKE_ARGS+=("-DREPR_RCC=ON")
fi
if [ ! -z "${TIDY+x}" ]; then
if [ -f /usr/local/bin/clang-fake ]; then
export CXX=clang-fake
export CC=clang-fake
else
export CXX=clang++
export CC=clang
fi
CMAKE_ARGS+=("-DCMAKE_EXPORT_COMPILE_COMMANDS=ON")
# Need to enable GUI tests so we can run clang-tidy on them.
# We don't actually run them.
CMAKE_ARGS+=("-DGUI_TESTS=ON")
fi
SRCDIR=/qtox
export CTEST_OUTPUT_ON_FAILURE=1
export QT_QPA_PLATFORM=offscreen
ccache --zero-stats
if [ "$MINIMAL" -eq 1 ]; then
BUILD_DIR=_build-minimal
cmake "$SRCDIR" \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DSTRICT_OPTIONS=ON \
-DUBSAN=ON \
-DSMILEYS=OFF \
-DUPDATE_CHECK=OFF \
-DSPELL_CHECK=OFF \
-GNinja \
"-B$BUILD_DIR" \
"${CMAKE_ARGS[@]}"
else
BUILD_DIR=_build-full
cmake "$SRCDIR" \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DSTRICT_OPTIONS=ON \
-DUBSAN=ON \
-DCODE_COVERAGE=ON \
-DUPDATE_CHECK=ON \
-GNinja \
"-B$BUILD_DIR" \
"${CMAKE_ARGS[@]}"
fi
cmake --build "$BUILD_DIR"
ccache --show-stats
if [ ! -z "${TIDY+x}" ]; then
if [ ! -z "${TIDY_FIX+x}" ]; then
clang-tidy -list-checks
run-clang-tidy -quiet -fix -format -p "$BUILD_DIR" \
-exclude-header-filter '/usr/.*' \
audio/include/ \
audio/src/ \
src/ \
test/include/ \
test/src/ \
util/include/ \
util/src/
else
tools/lsp_tidy.py --compile-commands-dir "$BUILD_DIR" --wait
fi
else
ctest -j"$(nproc)" --test-dir "$BUILD_DIR" --output-on-failure
fi