-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
71 lines (60 loc) · 2.03 KB
/
build.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
#!/bin/bash
################################################################################
# Usage: #
# No flags .. Configure CMake and build #
# -c ........ Clean configure and build (empty build directory first) #
# -b ........ Build only #
# -r ........ Build and run (Equivalent to Visual Studio play button) #
# -c-rel .... Clean configure and build in release mode #
# -b-rel .... Build in release mode #
# -r-rel .... Build and run in release mode #
# -v ........ Verbose flag #
################################################################################
USAGE="Usage: $(basename $0) [ -c | -b | -r | -c-rel | -b-rel | -r-rel ] [ -v ]"
VERBOSE=""
# Empty the build directory
clean () {
rm -r build/*
}
# Generate the CMake files in Debug
generate () {
cmake -S . -B build ..
}
# Build the project in Debug
build () {
cmake --build build --config Debug -j $VERBOSE
}
# Run the executable
run () {
pushd build/Debug/
./CompetitiveParkingSimulator
popd
}
# Generate the CMake files in Release
generate_release () {
cmake -S . -B build ..
}
# Build the project in Release
build_release () {
cmake --build build --config Release -j $VERBOSE
}
# Run the executable in Rleease
run_release () {
pushd build/Release/
./CompetitiveParkingSimulator
popd
}
for arg; do
case $arg in
-c) clean && generate && build ; exit 0 ;;
-b) build ; exit 0 ;;
-r) build && run ; exit 0 ;;
-c-rel) clean && generate_release && build_release ; exit 0 ;;
-b-rel) build_release ; exit 0 ;;
-r-rel) build_release && run_release ; exit 0 ;;
-v) VERBOSE="-v" ;;
*) echo -e "unrecognized option $arg\n$USAGE" >&2; exit 1 ;;
esac
done
# Default action
generate && build