-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·57 lines (47 loc) · 1.21 KB
/
run.sh
File metadata and controls
executable file
·57 lines (47 loc) · 1.21 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
#!/bin/bash
set -e
ensure_dir() {
if [[ ! -e "$1" ]]; then
echo "Setting up $1" >&2
mkdir -p "$1"
fi
}
ensure_dir "build/debug";
ensure_dir "build/test";
build_object() {
cc \
-I./include \
-I./thirdparty/Unity \
-Wall \
-Wextra \
-pedantic \
-std=c23 \
-g \
-Wno-char-subscripts \
-Wno-gnu-statement-expression-from-macro-expansion \
-Wno-gnu-case-range \
-Wgnu-zero-variadic-macro-arguments \
-Werror=incompatible-pointer-types \
-c $1 \
-o $2
}
for file in $(ls src); do
build_object "src/$file" "build/debug/${file%.*}.o"
done
if [[ $1 == "test" ]]; then
build_object "thirdparty/Unity/unity.c" "build/test/unity.o"
# use the same objs, but remove main to avoid duplicating symbol
cp build/debug/*.o build/test/
rm build/test/main.o
for file in $(ls tests); do
obj="build/test/${file%.*}.o"
bin="build/test/${file%.*}"
build_object "tests/$file" $obj
cc build/test/*.o -o $bin
./$bin
rm $obj # so next test doesn't duplicate main
done
else
cc build/debug/*.o -o build/debug/main
./build/debug/main
fi