summaryrefslogtreecommitdiff
path: root/tests/cross_test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cross_test.sh')
-rw-r--r--tests/cross_test.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/cross_test.sh b/tests/cross_test.sh
new file mode 100644
index 0000000..6c0efa2
--- /dev/null
+++ b/tests/cross_test.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+# The term core compiles as strict C11 for the platforms a host may embed
+# it on. zig cc supplies the cross compilers. The aarch64 targets build the
+# NEON paths, and windows-gnu builds the Windows path of compat.h. The
+# amalgamation, one term.c, compiles the same way.
+set -euo pipefail
+root=${1:-$(dirname "$0")/..}
+cd "$root/src"
+command -v zig >/dev/null || { echo "zig not found; skipping"; exit 77; }
+
+out=$(mktemp -d)
+trap 'rm -rf "$out"' EXIT
+python3 "$root/tools/amalgamate.py" "$root" "$out/amalgamation"
+status=0
+for target in aarch64-linux-gnu x86_64-macos aarch64-macos x86_64-windows-gnu; do
+ for src in *.c osc/*.c; do
+ zig cc -target "$target" -std=c11 -O2 -Wall -Wextra -Wpedantic -Werror \
+ -I. -I../include/term -c "$src" -o "$out/obj.o" || { echo "$target: $src fails" >&2; status=1; }
+ done
+ zig cc -target "$target" -std=c11 -O2 -Wall -Wextra -Wpedantic -Werror \
+ -c "$out/amalgamation/term.c" -o "$out/obj.o" ||
+ { echo "$target: the amalgamation fails" >&2; status=1; }
+done
+exit $status