42 lines
1.1 KiB
Bash
Executable File
42 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# run.sh — build (if needed) and launch the OTP cipher interactive mode,
|
|
# or pass any arguments straight through to the binary.
|
|
#
|
|
# Usage:
|
|
# ./run.sh # interactive mode
|
|
# ./run.sh generate 1GB # command-line mode
|
|
# ./run.sh list
|
|
# ./run.sh split <chksum> [state|grant]
|
|
# ./run.sh test # run the partition test suite
|
|
|
|
set -e
|
|
|
|
# Resolve the directory this script lives in so it works from anywhere
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$SCRIPT_DIR"
|
|
|
|
ARCH=$(uname -m)
|
|
BIN="build/otp-$ARCH"
|
|
|
|
# Build if the binary is missing or sources are newer than the binary
|
|
needs_build=0
|
|
if [ ! -x "$BIN" ]; then
|
|
needs_build=1
|
|
elif [ -n "$(find src Makefile -newer "$BIN" -name '*.c' -o -name '*.h' -newer "$BIN" 2>/dev/null | head -1)" ]; then
|
|
needs_build=1
|
|
fi
|
|
|
|
if [ "$needs_build" -eq 1 ]; then
|
|
echo "[run.sh] Building..."
|
|
make > /dev/null
|
|
echo "[run.sh] Build complete: $BIN"
|
|
fi
|
|
|
|
# Test passthrough
|
|
if [ "${1:-}" = "test" ]; then
|
|
shift
|
|
exec ./tests/test_partition.sh "$BIN" "$@"
|
|
fi
|
|
|
|
exec "$BIN" "$@"
|