Files
wikideck/scripts/build-randomx.sh
T
2026-10-19 16:47:27 -04:00

22 lines
1.1 KiB
Bash

#!/bin/sh
set -eu
# Usage: sh scripts/build-randomx.sh [--test]; JOBS defaults to a modest two compiler jobs.
tests=OFF
case "${1-}" in
'') ;;
--test) tests=ON; shift ;;
*) printf '%s\n' 'usage: build-randomx.sh [--test]' >&2; exit 2 ;;
esac
[ "$#" -eq 0 ] || { printf '%s\n' 'unexpected argument' >&2; exit 2; }
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
build=${RANDOMX_BUILD_DIR:-"$root/native/build"}
jobs=${JOBS:-2}
case "$jobs" in ''|*[!0-9]*) printf '%s\n' 'JOBS must be 1..64' >&2; exit 2 ;; esac
[ "$jobs" -ge 1 ] && [ "$jobs" -le 64 ] || { printf '%s\n' 'JOBS must be 1..64' >&2; exit 2; }
command -v cmake >/dev/null 2>&1 || { printf '%s\n' 'CMake 3.24+ is required' >&2; exit 1; }
command -v git >/dev/null 2>&1 || { printf '%s\n' 'Git is required' >&2; exit 1; }
cmake -S "$root/native" -B "$build" -DCMAKE_BUILD_TYPE=Release "-DWIKIDECK_RANDOMX_TESTS=$tests"
cmake --build "$build" --config Release --target wikideck-randomx --parallel "$jobs"
if [ "$tests" = ON ]; then ctest --test-dir "$build" -C Release --output-on-failure; fi
printf 'Built native RandomX engine in %s\n' "$build"