-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·94 lines (88 loc) · 3.03 KB
/
Copy pathbuild
File metadata and controls
executable file
·94 lines (88 loc) · 3.03 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
#!/bin/bash
# build and run the executable
if [[ "$1" == "run" ]]; then
if [[ -z "$2" || "$2" == "--debug" || "$2" == "-d" ]]; then
./out/debug/main 2>/dev/null || echo "Debug target not found. Run 'mac build' first"
elif [[ "$2" == "--release" || "$2" == "-r" ]]; then
./out/release/main 2>/dev/null || echo "Release target not found. Run 'mac build --release' first"
else
echo "Invalid option. Use --debug or --release."
exit 1
fi
# build the executable
elif [[ "$1" == "build" ]]; then
if [[ -z "$2" || "$2" == "--debug" || "$2" == "-d" ]]; then
mkdir -p out/debug
# build main target
clang++ \
-std=c++17 \
-Iincludes \
$(find src -name "*.cpp") \
-o out/debug/main
# build test target
clang++ \
-std=c++17 \
-Iincludes \
-Iextras/googletest/googletest \
-Iextras/googletest/googletest/include \
$(find tests -name "*.cpp") \
src/core.cpp \
extras/googletest/googletest/src/gtest-all.cc \
-pthread -o out/debug/test_main
elif [[ "$2" == "--release" || "$2" == "-r" ]]; then
mkdir -p out/release
# build main target
clang++ \
-O3 -march=native \
-std=c++17 \
-Iincludes \
$(find src -name "*.cpp") \
-o out/release/main
# build test target
clang++ \
-std=c++17 \
-O3 -march=native \
-Iincludes \
-Iextras/googletest/googletest \
-Iextras/googletest/googletest/include \
$(find tests -name "*.cpp") \
src/core.cpp \
extras/googletest/googletest/src/gtest-all.cc \
-pthread -o out/release/test_main
elif [[ "$2" == "--all" || "$2" == "-a" ]]; then
# Build for debug
./build build -d
# Build for release
./build build -r
else
echo "Invalid option. Use --debug or --release or --all."
exit 1
fi
# unittest
elif [[ "$1" == "test" ]]; then
if [[ -z "$2" || "$2" == "--debug" || "$2" == "-d" ]]; then
./out/debug/test_main 2>/dev/null || echo "Debug test target not found. Run 'mac build' first"
elif [[ "$2" == "--release" || "$2" == "-r" ]]; then
./out/release/test_main 2>/dev/null || echo "Release test target not found. Run 'mac build --release' first"
else
echo "No test target found!!"
exit 1;
fi
# clean the build directory
elif [[ "$1" == "clean" ]]; then
if [[ "$2" == "--debug" || "$2" == "-d" ]]; then
rm -rf out/debug
echo "Cleaned debug build directory."
elif [[ "$2" == "--release" || "$2" == "-r" ]]; then
rm -rf out/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 | test | clean | help] [--debug | --release]"
exit 1
fi