-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·63 lines (51 loc) · 1.09 KB
/
build.sh
File metadata and controls
executable file
·63 lines (51 loc) · 1.09 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
#!/usr/bin/env bash
set -euo pipefail
# Print and execute a command with a banner
execute_cmd() {
echo ">>> $*"
eval "$@"
}
# Display help message
display_help() {
echo "Usage:"
echo " ./build.sh cmake \"[CMake Config Options]\" [CMake Build Options]"
echo " ./build.sh make [GNU Make Options]"
echo " ./build.sh clean"
echo " ./build.sh clean_all"
echo " ./build.sh --help | -h"
}
# Exit if no arguments were provided
if [ $# -eq 0 ]; then
display_help
exit 1
fi
# Parse first argument
case "$1" in
cmake)
shift
mkdir -p build && cd build
CONFIG_OPTS="${1:-}" # Use empty string if not set
if [ $# -gt 0 ]; then shift; fi
CMD="cmake $CONFIG_OPTS .. && cmake --build . $*"
;;
make)
shift
CMD="make $*"
;;
clean)
CMD="rm -rf build"
;;
clean_all)
CMD="rm -rf build .cache"
;;
-h|--help)
display_help
exit 0
;;
*)
display_help
exit 1
;;
esac
# Run the final command
execute_cmd "$CMD"