aboutsummaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..4cf5e42
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,49 @@
+#!/bin/env bash
+
+cc="gcc"
+ld="gcc"
+
+rm -rf ./lib/
+rm -rf ./bin/
+mkdir ./lib/
+mkdir ./bin/
+
+echo "[BUILD] entry.c"
+
+cflags="-std=c99 -Wall -Wextra -g -Wno-error -pedantic"
+$cc $cflags \
+ -c -o lib/ungrateful.o \
+ -g src/ungrateful.c
+
+if [[ $? -ne 0 ]]; then
+ exit
+fi
+
+if [[ $1 == "no_tests" ]]; then
+ exit
+fi
+
+echo
+
+for test in tests/*.c; do
+ fname=$(basename -- "$test")
+ fname="${fname%.*}"
+
+ echo "[BUILD] $test"
+
+ $cc $cflags -o bin/$fname $test lib/ungrateful.o -Isrc/
+done
+
+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