bf1c41f3e1
Official build / Build (push) Failing after 1m20s
(Scripts generated by Antigravity with Gemini Flash 3.5)
78 lines
1.8 KiB
Bash
Executable File
78 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# =======================
|
|
CUSTOM_PCSX2_PATH="" # e.g. "/usr/bin/pcsx2" or "flatpak run net.pcsx2.PCSX2"
|
|
# =======================
|
|
|
|
get_target_elf_name() {
|
|
if [ -f "./Makefile" ]; then
|
|
grep -oP '\S+\.elf' Makefile | head -n 1
|
|
else
|
|
echo ""
|
|
fi
|
|
}
|
|
|
|
find_pcsx2() {
|
|
if [ -n "$CUSTOM_PCSX2_PATH" ]; then
|
|
echo "$CUSTOM_PCSX2_PATH"
|
|
return 0
|
|
fi
|
|
|
|
# Check flatpak
|
|
if command -v flatpak >/dev/null 2>&1 && flatpak list | grep -q "net.pcsx2.PCSX2"; then
|
|
echo "flatpak run net.pcsx2.PCSX2"
|
|
return 0
|
|
fi
|
|
|
|
# Check if pcsx2-qt is in PATH
|
|
if command -v pcsx2-qt >/dev/null 2>&1; then
|
|
echo "pcsx2-qt"
|
|
return 0
|
|
fi
|
|
|
|
# Check if pcsx2 is in PATH
|
|
if command -v pcsx2 >/dev/null 2>&1; then
|
|
echo "pcsx2"
|
|
return 0
|
|
fi
|
|
|
|
echo "Error: PCSX2 not found! Please install it, put it in PATH, or specify CUSTOM_PCSX2_PATH in this script." >&2
|
|
exit 1
|
|
}
|
|
|
|
run_pcsx2() {
|
|
local pcsx2_cmd
|
|
pcsx2_cmd=$(find_pcsx2)
|
|
|
|
local elf_name
|
|
elf_name=$(get_target_elf_name)
|
|
if [ -z "$elf_name" ]; then
|
|
echo "Error: Could not find target ELF name in Makefile!" >&2
|
|
exit 1
|
|
fi
|
|
|
|
local target_file
|
|
target_file="$(pwd)/bin/$elf_name"
|
|
|
|
if [ ! -f "$target_file" ]; then
|
|
echo "Error: ELF file not found at $target_file. Did you build the project?" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Kill existing PCSX2 instances
|
|
if [[ "$pcsx2_cmd" == *"flatpak"* ]]; then
|
|
pkill -f "net.pcsx2.PCSX2" >/dev/null 2>&1 || true
|
|
pkill -f "pcsx2-qt" >/dev/null 2>&1 || true
|
|
else
|
|
local bin_name
|
|
bin_name=$(basename "$pcsx2_cmd")
|
|
pkill "$bin_name" >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
echo "Running PCSX2: $pcsx2_cmd -elf $target_file"
|
|
|
|
# Run PCSX2 in the background
|
|
$pcsx2_cmd -elf "$target_file" &
|
|
}
|
|
|
|
run_pcsx2
|