-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.sh
More file actions
executable file
·97 lines (83 loc) · 1.83 KB
/
Copy pathshell.sh
File metadata and controls
executable file
·97 lines (83 loc) · 1.83 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
#!/usr/bin/env bash
set -e
if [[ -t 1 ]]; then
RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
BLUE='\033[34m'
RESET='\033[0m'
else
RED=''
GREEN=''
YELLOW=''
BLUE=''
RESET=''
fi
CMAKE_DEFINITIONS=""
CMAKE_FLAGS=""
BUILD_TYPE_SET=false
SHOULD_RUN=true
SHOULD_CLEAN=false
SHOULD_CLEAN_ONLY=false
for arg in "$@"; do
case "$arg" in
--force)
CMAKE_FLAGS+=" --fresh"
;;
--debug)
$BUILD_TYPE_SET && {
echo "Error: multiple build types specified" >&2
exit 1
}
BUILD_TYPE_SET=true
CMAKE_DEFINITIONS+=" -DCMAKE_BUILD_TYPE=Debug"
;;
--release)
$BUILD_TYPE_SET && {
echo "Error: multiple build types specified" >&2
exit 1
}
BUILD_TYPE_SET=true
CMAKE_DEFINITIONS+=" -DCMAKE_BUILD_TYPE=Release"
;;
--debug-token)
CMAKE_DEFINITIONS+=" -DDEBUG_TOKEN=ON"
;;
--build)
SHOULD_RUN=false
;;
--clean)
$SHOULD_CLEAN_ONLY && {
echo "Error: --clean and --clean-only cannot be used together" >&2
exit 1
}
SHOULD_CLEAN=true
;;
--clean-only)
$SHOULD_CLEAN && {
echo "Error: --clean and --clean-only cannot be used together" >&2
exit 1
}
SHOULD_CLEAN_ONLY=true
;;
esac
done
if [ "$SHOULD_CLEAN_ONLY" = true ]; then
echo -e "${RED}Cleaning build directory...${RESET}"
rm -rf "$(dirname "$0")/build"
exit 0
fi
if [ "$SHOULD_CLEAN" = true ]; then
echo -e "${RED}Cleaning build directory...${RESET}"
rm -rf "$(dirname "$0")/build"
fi
(
cd "$(dirname "$0")"
echo -e "${YELLOW}Configuring and building project...${RESET}"
cmake $CMAKE_FLAGS -S . -B build $CMAKE_DEFINITIONS
cmake --build build
)
if [ "$SHOULD_RUN" = true ]; then
echo -e "${GREEN}Running shell executable...${RESET}"
exec ./build/shell
fi