hypertwist/scripts/run-hypertwist-sentrux-source-only.sh
2026-06-22 23:24:30 +00:00

76 lines
2 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
temp_root="${TMPDIR:-/tmp}/hypertwist-sentrux-source-only"
repo_local_sentrux_binary="$repo_root/sentrux"
repo_local_sentrux_windows_binary="$repo_root/sentrux.exe"
local_sentrux_binary="/home/dev/src/VectorShell/sentrux/target/release/sentrux"
local_sentrux_manifest="/home/dev/src/VectorShell/sentrux/Cargo.toml"
resolve_sentrux_command() {
if [[ -n "${HYPERTWIST_SENTRUX_BINARY:-}" && -x "${HYPERTWIST_SENTRUX_BINARY}" ]]; then
printf '%s\n' "${HYPERTWIST_SENTRUX_BINARY}"
return 0
fi
if [[ -x "$repo_local_sentrux_binary" ]]; then
printf '%s\n' "$repo_local_sentrux_binary"
return 0
fi
if [[ -x "$repo_local_sentrux_windows_binary" ]]; then
printf '%s\n' "$repo_local_sentrux_windows_binary"
return 0
fi
if command -v sentrux >/dev/null 2>&1; then
printf 'sentrux\n'
return 0
fi
if [[ -x "$local_sentrux_binary" ]]; then
printf '%s\n' "$local_sentrux_binary"
return 0
fi
if command -v cargo >/dev/null 2>&1 && [[ -f "$local_sentrux_manifest" ]]; then
printf 'cargo run --quiet --manifest-path %q --bin sentrux --\n' "$local_sentrux_manifest"
return 0
fi
return 1
}
sentrux_command="$(resolve_sentrux_command)" || {
echo "Unable to locate sentrux. Provide HYPERTWIST_SENTRUX_BINARY, add sentrux to PATH, place a repo-local sentrux binary at $repo_root, or keep /home/dev/src/VectorShell/sentrux available." >&2
exit 1
}
rm -rf "$temp_root"
mkdir -p "$temp_root/.sentrux"
cp "$repo_root/.sentrux/rules.toml" "$temp_root/.sentrux/rules.toml"
copy_targets=(
"UnrealHyperTwist/Source"
"Content/Browser/src"
"website/src"
"website/server/src"
"scripts"
)
for target in "${copy_targets[@]}"; do
source_path="$repo_root/$target"
if [[ ! -e "$source_path" ]]; then
continue
fi
destination_path="$temp_root/$target"
mkdir -p "$(dirname "$destination_path")"
cp -R "$source_path" "$destination_path"
done
(
cd "$repo_root"
eval "$sentrux_command" check "$temp_root"
)