blob: a2f91ecce780ca123a7b32ee0307354f38e7a24a (
plain)
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
|
#!/bin/env bash
cc="gcc"
ld="gcc"
ar="ar"
cflags="-std=c99 -fPIC -Wall -Wextra -g -Wno-error -pedantic -lm -ffast-math"
proc=$(nproc)
rm -rf ./include/
rm -rf ./lib/
rm -rf ./bin/
rm -rf ./obj/
mkdir ./include/
mkdir ./lib/
mkdir ./bin/
mkdir ./obj/
echo "[BUILD] ungrateful.c"
$cc $cflags \
-c -o obj/ungrateful.o \
-g src/ungrateful.c
if [[ $? -ne 0 ]]; then
exit
fi
echo "[BUILD] cynic.c"
$cc $cflags -Isrc/ \
-c -o obj/cynic.o \
-g src/cynic.c
if [[ $? -ne 0 ]]; then
exit
fi
$ar rcs lib/libungrateful.a obj/ungrateful.o
$ar rcs lib/libcynic.a obj/cynic.o
cp src/ungrateful.h include/ungrateful.h
cp src/cynic.h include/cynic.h
# ------------ Tests from here
#
if [[ $1 == "no_tests" ]]; then
exit
fi
echo
for test in tests/un/*.c; do
fname=$(basename -- "$test")
fname="${fname%.*}"
echo "[BUILD] $test"
$cc $cflags -o bin/$fname $test -Llib/ -Iinclude/ -lungrateful &
if [[ $(jobs -r -p | wc -l) -ge $proc ]]; then
wait
fi
done
wait
for test in tests/cyn/*.c; do
fname=$(basename -- "$test")
fname="${fname%.*}"
echo "[BUILD] $test"
$cc $cflags -o bin/$fname $test -Llib/ -Iinclude/ -lungrateful -lcynic &
if [[ $(jobs -r -p | wc -l) -ge $proc ]]; then
wait
fi
done
wait
echo
for case in bin/*; do
if [[ $1 == "quiet" ]]; then
$case > /dev/null 2>&1
else
$case
fi
if [[ $? -eq 0 ]]; then
echo "[DONE] $case"
else
echo "[FAIL] $case"
fi
done
|