summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLinnnus <[email protected]>2025-04-08 01:07:22 +0000
committerLinnnus <[email protected]>2025-04-08 01:07:34 +0000
commit8dd0c4f27aae02dd60f029db4cf03f9902cba26f (patch)
tree829c4bc0917f6615c55ae61d49932179c038c1e5 /scripts
feat: Initial commit
At this point we have some allocation routines but no work on the actual language has been done.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build_debug.sh5
-rwxr-xr-xscripts/build_release.sh5
-rwxr-xr-xscripts/git-pre-commit-hook.sh12
-rwxr-xr-xscripts/unit_test.sh5
4 files changed, 27 insertions, 0 deletions
diff --git a/scripts/build_debug.sh b/scripts/build_debug.sh
new file mode 100755
index 0000000..fcdf16a
--- /dev/null
+++ b/scripts/build_debug.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e -u -o pipefail
+mkdir -p bin/debug
+clang -std=c23 -ggdb -O0 -Wall -Wextra -fsanitize=undefined,address -o bin/debug/sand src/{cli,core}/*.c
+clang -std=c23 -ggdb -O0 -Wall -Wextra -fsanitize=undefined,address -o bin/debug/unit src/{unit,core}/*.c
diff --git a/scripts/build_release.sh b/scripts/build_release.sh
new file mode 100755
index 0000000..6f42aed
--- /dev/null
+++ b/scripts/build_release.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e -u -o pipefail
+mkdir -p bin/release
+clang -std=c23 -O3 -Wall -Wextra -o bin/release/sand src/{cli,core}/*.c
+clang -std=c23 -O3 -Wall -Wextra -o bin/release/unit src/{unit,core}/*.c
diff --git a/scripts/git-pre-commit-hook.sh b/scripts/git-pre-commit-hook.sh
new file mode 100755
index 0000000..d6297e7
--- /dev/null
+++ b/scripts/git-pre-commit-hook.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+set -e -u -o pipefail
+
+# All of this is output for humans, not programs.
+exec >&2
+
+unit="$(scripts/unit_test.sh)"
+if [ $? -ne 0 ]; then
+ echo "$unit"
+ echo "You have failing unit tests. Aborting git commit."
+ exit 1
+fi
diff --git a/scripts/unit_test.sh b/scripts/unit_test.sh
new file mode 100755
index 0000000..6369974
--- /dev/null
+++ b/scripts/unit_test.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e -u -o pipefail
+mode="${1:-debug}"
+scripts/build_$mode.sh
+bin/$mode/unit || gdb bin/$mode/unit