forked from luebking/qarma
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·100 lines (76 loc) · 1.96 KB
/
build.sh
File metadata and controls
executable file
·100 lines (76 loc) · 1.96 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
#!/usr/bin/env bash
################################################################################
## @title Initialization
################################################################################
set -euo pipefail
################################################################################
## @title Functions
################################################################################
usage() {
cat <<-TXT
Usage: $0 [-b BUILD_TOOL] [-c]
-b BUILD_TOOL Build tool to use (cmake|qmake). Default is cmake.
-c Clean before building.
TXT
}
################################################################################
## @title Arguments
################################################################################
build_tool="cmake"
clean_build=false
while getopts ":b:ch" opt; do
case "$opt" in
b)
build_tool=$OPTARG
;;
c)
clean_build=true
;;
h)
usage
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
usage
exit 1
;;
esac
done
################################################################################
## @title Script
################################################################################
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
cd "$script_dir" || { echo "Can't enter $script_dir" >&2; exit 1; }
nb_procs=$(nproc)
case "$build_tool" in
cmake)
echo "[INFO] Building with CMake..."
if [[ $clean_build == true ]]; then
echo "[INFO] Cleaning..."
rm -rf build/
fi
cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build build -j "$nb_procs"
cp build/compile_commands.json .
cp build/guid .
;;
qmake)
echo "[INFO] Building with qmake..."
if [[ $clean_build == true ]]; then
echo "[INFO] Cleaning..."
make distclean || true
fi
qmake guid.pro
make -j "$nb_procs"
;;
*)
usage
exit 1
;;
esac