-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·52 lines (49 loc) · 1.83 KB
/
Copy pathbuild
File metadata and controls
executable file
·52 lines (49 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
#!/bin/bash
# build and run the executable
if [[ "$1" == "run" ]]; then
if [[ -z "$2" || "$2" == "--debug" ]]; then
cmake --preset unix-debug && cmake --build ./out/unix-debug && ./out/unix-debug/main
elif [[ "$2" == "--release" ]]; then
cmake --preset unix-release && cmake --build ./out/unix-release && ./out/unix-release/main
else
echo "Invalid option. Use --debug or --release."
exit 1
fi
# build the executable
elif [[ "$1" == "build" ]]; then
if [[ -z "$2" || "$2" == "--debug" ]]; then
echo "Building debug version..."
cmake --preset unix-debug && cmake --build ./out/unix-debug
elif [[ "$2" == "--release" ]]; then
echo "Building release version..."
cmake --preset unix-release && cmake --build ./out/unix-release
elif [[ "$2" == "--all" ]]; then
echo "Building both debug and release versions..."
# Build for debug
echo -e "\e[32mBuilding debug version...\e[0m"
cmake --preset unix-debug && cmake --build ./out/unix-debug
# Build for release
echo -e "\e[32mBuilding release version...\e[0m"
cmake --preset unix-release && cmake --build ./out/unix-release
else
echo "Invalid option. Use --debug or --release or --all."
exit 1
fi
# clean the build directory
elif [[ "$1" == "clean" ]]; then
if [[ "$2" == "--debug" ]]; then
rm -rf ./out/unix-debug
echo "Cleaned debug build directory."
elif [[ "$2" == "--release" ]]; then
rm -rf ./out/unix-release
echo "Cleaned release build directory."
else
rm -rf ./out
echo "Cleaned all build directories."
fi
elif [[ "$1" == "help" ]]; then
glow README.md 2>/dev/null || cat README.md
else
echo "Usage: ./build [build | run | clean | help] [--debug | --release]"
exit 1
fi