Repository navigation
Expand file tree
/
Copy pathrun.sh
More file actions
79 lines (79 loc) · 4.02 KB
/
Copy pathrun.sh
File metadata and controls
79 lines (79 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
set -euo pipefail
cd -- "$(dirname -- "$0")"
if [[ ${1:-} == --software ]]; then
shift
if [[ -z ${VK_DRIVER_FILES:-} ]]; then
for candidate in /run/opengl-driver/share/vulkan/icd.d/lvp_icd*.json /usr/share/vulkan/icd.d/lvp_icd*.json; do
if [[ -f $candidate ]]; then export VK_DRIVER_FILES=$candidate; break; fi
done
fi
if [[ -z ${VK_DRIVER_FILES:-} ]]; then echo 'Lavapipe not found; set VK_DRIVER_FILES.' >&2; exit 1; fi
export VK_LOADER_LAYERS_DISABLE='~implicit~'
fi
# GOW3_PREBUILT=1 (packaged builds, the AppImage): out/gow3-probe and its GPU library are installed
# next to this script; nothing is built and no nix-shell is needed.
# GOW3_DATA_DIR: writable directory for the generated files (out/), saves (user/) and gow3.ini;
# by default this directory.
data=${GOW3_DATA_DIR:-.}
out=$data/out
mkdir -p "$out"
export GOW3_CONFIG=${GOW3_CONFIG:-$data/gow3.ini}
# FSR 4.1.1 assets (tools/fsr4cap/build_assets.sh): next to run.sh or in the data directory.
if [[ -z ${GOW3_FSR411_DIR:-} && ! -d fsr4_411 && -d $data/fsr4_411 ]]; then
export GOW3_FSR411_DIR=$data/fsr4_411
fi
if [[ -z ${GOW3_PREBUILT:-} && -z ${GOW3_IN_NIX_SHELL:-} ]] && ! { command -v pkg-config >/dev/null && pkg-config --exists vulkan sdl3; } && command -v nix-shell >/dev/null; then
args=''; if (( $# )); then args=$(printf '%q ' "$@"); fi
exec env GOW3_IN_NIX_SHELL=1 nix-shell shell.nix --run "bash run.sh $args"
fi
if [[ -z ${PYTHON:-} ]]; then
PYTHON=$(command -v python3 || true)
if [[ -z $PYTHON ]]; then
for candidate in /nix/store/*-python3-*/bin/python3; do
if [[ -x $candidate ]]; then PYTHON=$candidate; break; fi
done
fi
fi
if [[ -z ${PYTHON:-} ]]; then echo 'Install Python 3 or set PYTHON.' >&2; exit 1; fi
# GOW3_GAME_DIR: the game's folder (eboot.bin, sce_module, ...); default next to this directory.
game=${GOW3_GAME_DIR:-../CUSA01623}
if [[ ! -f $game/eboot.bin ]]; then echo "No eboot.bin in $game (set GOW3_GAME_DIR)." >&2; exit 1; fi
original_game=$game
game=$("$PYTHON" scripts/mods.py "$game" --out "$out" \
--mods-dir "${GOW3_MODS_DIR:-$data/mods}" --config "${GOW3_MODS_CONFIG:-$data/mods.json}" \
--enabled "${GOW3_MODS_ENABLED:-1}")
# A private merged view lasts for this launch, including restarts. Cleanup only our own view.
if [[ $game != "$(realpath "$original_game")" ]]; then
mod_game=$game
trap '"$PYTHON" -c '\''import shutil,sys; shutil.rmtree(sys.argv[1])'\'' "$mod_game"' EXIT
fi
"$PYTHON" scripts/prepare.py "$game" --out "$out"
"$PYTHON" scripts/link_libc.py "$game" --out "$out"
"$PYTHON" scripts/link_modules.py "$game" --out "$out"
"$PYTHON" scripts/content_profile.py "$game" --out "$out" --sku "${GOW3_CONTENT_SKU:-full}"
# GOW3_PATCHES adds patch names ("a;b") to the game's built-in patch file.
"$PYTHON" scripts/patches.py --out "$out" --extra "${GOW3_PATCHES:-}" --game-dir "$game" --patches-dir "${GOW3_PATCHES_DIR:-$data/patches}" --patches-config "${GOW3_PATCHES_CONFIG:-$data/patches.json}"
export GOW3_VBLANK_HZ=${GOW3_VBLANK_HZ:-60}
# FSR 4: faster post passes next to the downloaded ones (incremental; tools/fsr4_optimize.sh).
if [[ -z ${GOW3_PREBUILT:-} && -d fsr4_shaders ]] && command -v spirv-cross >/dev/null; then
bash tools/fsr4_optimize.sh || echo 'FSR 4: optimized post passes not built' >&2
fi
if [[ -n ${GOW3_PREBUILT:-} ]]; then
probe=${GOW3_PROBE:-bin/gow3-probe}
else
bash build.sh
probe=out/gow3-probe
fi
probe_args=("$out/boot-linked.bin" --content-profile "$out/content.bin" --patches "$out/patches.bin" --app0 "$game" --user "${GOW3_USER_DIR:-$data/user}" --timeout "${GOW3_TIMEOUT:-0}" "$@")
if [[ -n ${mod_game:-} ]]; then
"$probe" "${probe_args[@]}" &
mod_pid=$!
trap 'kill -TERM "$mod_pid" 2>/dev/null || true' TERM INT
mod_status=0
wait "$mod_pid" || mod_status=$?
# An interrupted wait must finish the child before removing its mounted view.
if kill -0 "$mod_pid" 2>/dev/null; then wait "$mod_pid" || mod_status=$?; fi
exit "$mod_status"
fi
exec "$probe" "${probe_args[@]}"