#!/usr/bin/env bash # Builds the libsodium C program and diffs its output against the Go program (run ./run.sh first). # With real libsodium headers installed, set LIBSODIUM_CFLAGS/LIBSODIUM_LIBS (or drop the shim). # Default: the machine's libsodium 1.0.20 shared library (no headers) plus the local shim header. set -euo pipefail cd "$(dirname "$0")" mkdir -p out SO="${LIBSODIUM_SO:-/nix/store/gaaqqkh7pvr85vh2vdclw8z2m4w1lq8q-libsodium-1.0.20/lib/libsodium.so}" if [ -n "${LIBSODIUM_LIBS:-}" ]; then gcc -std=c11 -Wall -Wextra -O2 ${LIBSODIUM_CFLAGS:-} -o out/spike-sodium c-libsodium/main.c $LIBSODIUM_LIBS else gcc -std=c11 -Wall -Wextra -O2 -Ic-libsodium/shim -o out/spike-sodium c-libsodium/main.c \ "$SO" -Wl,-rpath,"$(dirname "$SO")" fi ./out/spike-sodium > out/sodium.txt diff out/go.txt out/sodium.txt && echo "go == c (libsodium)"