hypertwist/scripts/bootstrap-hypertwist-sentrux.sh
2026-06-24 02:19:26 +00:00

99 lines
2.6 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
dest_dir="$repo_root/tools/sentrux/bin"
dest_linux="$dest_dir/sentrux"
dest_windows="$dest_dir/sentrux.exe"
vector_sentrux_binary="/home/dev/src/VectorShell/sentrux/target/release/sentrux"
vector_sentrux_manifest="/home/dev/src/VectorShell/sentrux/Cargo.toml"
scriptorium_sentrux_windows="/home/dev/src/ScriptoriumAI/sentrux.exe"
usage() {
cat <<'EOF'
Usage:
scripts/bootstrap-hypertwist-sentrux.sh [--if-missing]
Materializes a repo-local sentrux binary under tools/sentrux/bin/ using the
best available retained seed on this machine.
Resolution order:
1. HYPERTWIST_SENTRUX_BINARY if explicitly provided
2. existing VectorShell Linux build artifact
3. local VectorShell source build via cargo
4. local ScriptoriumAI Windows binary
The resulting analyzer then lives under HyperTwist-owned tools/sentrux/bin/
so later runs do not need to execute directly from sibling repos.
EOF
}
copy_binary() {
local source_path="$1"
local destination_path="$2"
mkdir -p "$dest_dir"
cp "$source_path" "$destination_path"
chmod +x "$destination_path" 2>/dev/null || true
printf 'Materialized sentrux at %s from %s\n' "$destination_path" "$source_path"
}
if [[ "${1:-}" == "--help" ]]; then
usage
exit 0
fi
if [[ "${1:-}" == "--if-missing" ]]; then
if [[ -x "$dest_linux" || -x "$dest_windows" ]]; then
printf 'Repo-local sentrux already present under %s\n' "$dest_dir"
exit 0
fi
elif [[ $# -gt 0 ]]; then
usage >&2
exit 1
fi
if [[ -n "${HYPERTWIST_SENTRUX_BINARY:-}" && -x "${HYPERTWIST_SENTRUX_BINARY}" ]]; then
case "${HYPERTWIST_SENTRUX_BINARY}" in
*.exe)
copy_binary "${HYPERTWIST_SENTRUX_BINARY}" "$dest_windows"
;;
*)
copy_binary "${HYPERTWIST_SENTRUX_BINARY}" "$dest_linux"
;;
esac
exit 0
fi
if [[ -x "$vector_sentrux_binary" ]]; then
copy_binary "$vector_sentrux_binary" "$dest_linux"
exit 0
fi
if command -v cargo >/dev/null 2>&1 && [[ -f "$vector_sentrux_manifest" ]]; then
cargo build --quiet --release --manifest-path "$vector_sentrux_manifest" --bin sentrux
if [[ -x "$vector_sentrux_binary" ]]; then
copy_binary "$vector_sentrux_binary" "$dest_linux"
exit 0
fi
fi
if [[ -f "$scriptorium_sentrux_windows" ]]; then
copy_binary "$scriptorium_sentrux_windows" "$dest_windows"
exit 0
fi
cat >&2 <<EOF
Unable to materialize a repo-local sentrux binary.
Checked:
- HYPERTWIST_SENTRUX_BINARY
- $vector_sentrux_binary
- $vector_sentrux_manifest
- $scriptorium_sentrux_windows
Provide HYPERTWIST_SENTRUX_BINARY directly or place a compatible sentrux binary
under tools/sentrux/bin/.
EOF
exit 1