-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·136 lines (105 loc) · 2.22 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·136 lines (105 loc) · 2.22 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env bash
set -e
BUILD_DIR="build"
show_help() {
echo "Usage: ./build.sh [command]"
echo
echo "Commands:"
echo " build Configure and build the project"
echo " run Build and run the program"
echo " test Build and run tests"
echo " debug Build Debug version"
echo " release Build Release version"
echo " clean Remove build artifacts"
echo " cmake Configure and build using CMake"
echo " all Run build, test, and run"
echo " help Show this help"
}
configure() {
echo "==> Configuring project..."
cmake -S . -B "$BUILD_DIR"
}
build() {
configure
echo "==> Building project..."
cmake --build "$BUILD_DIR"
}
run() {
build
echo "==> Running program..."
"./$BUILD_DIR/tinyjson"
}
test() {
build
echo "==> Running tests..."
ctest --test-dir "$BUILD_DIR" --output-on-failure
}
debug() {
echo "==> Configuring Debug build..."
cmake -S . -B "$BUILD_DIR" \
-DCMAKE_BUILD_TYPE=Debug
echo "==> Building Debug version..."
cmake --build "$BUILD_DIR"
}
release() {
echo "==> Configuring Release build..."
cmake -S . -B "$BUILD_DIR" \
-DCMAKE_BUILD_TYPE=Release
echo "==> Building Release version..."
cmake --build "$BUILD_DIR"
}
clean() {
echo "==> Removing build directory..."
rm -rf "$BUILD_DIR"
echo "==> Clean complete."
}
cmake_build() {
echo "==> CMake configure..."
cmake -S . -B "$BUILD_DIR"
echo "==> CMake build..."
cmake --build "$BUILD_DIR"
echo "==> CMake tests..."
ctest --test-dir "$BUILD_DIR" --output-on-failure
}
all() {
build
test
echo "==> All tests passed."
echo "==> Running program..."
"./$BUILD_DIR/tinyjson"
}
case "${1:-help}" in
build)
build
;;
run)
run
;;
test)
test
;;
debug)
debug
;;
release)
release
;;
clean)
clean
;;
cmake)
cmake_build
;;
all)
all
;;
help|-h|--help)
show_help
;;
*)
echo "Unknown command: $1"
echo
show_help
exit 1
;;
esac