-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·51 lines (41 loc) · 1.05 KB
/
build.sh
File metadata and controls
executable file
·51 lines (41 loc) · 1.05 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
#!/usr/bin/env bash
set -euo pipefail
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
BUILD_DIR="$PROJECT_ROOT/build"
TESTS_DIR="$PROJECT_ROOT/tests"
run=0
test=0
clean=0
for arg in "$@"; do
case $arg in
--clean)
clean=1
;;
--run)
run=1
;;
--test)
test=1
;;
--help | *)
echo "build.sh [--clean] [--test] [--run]"
exit 0
;;
esac
done
if [[ "$clean" -eq 1 ]] && [[ -e "$BUILD_DIR" ]]; then
rm -rf "$BUILD_DIR"
rm -rf "$PROJECT_ROOT/.cache"
fi
mkdir -p "$BUILD_DIR"
cmake -G "Unix Makefiles" -B "$BUILD_DIR" -S "$PROJECT_ROOT" -DCMAKE_BUILD_TYPE=Debug
cmake --build "$BUILD_DIR" -j"$(nproc)"
if [ "$test" -eq 1 ]; then
ctest --test-dir build --output-on-failure
# cleanup after tests
[[ -e "$TESTS_DIR/test_dir" ]] && rm -rf "$TESTS_DIR/test_dir"
[[ -e "$TESTS_DIR/modified_dir" ]] && rm -rf "$TESTS_DIR/modified_dir"
fi
if [[ "$run" -eq 1 ]]; then
"$BUILD_DIR/QtFiles"
fi