Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
Map the game's Steam library to drive S:
NotProtonNot5e3b3d15432d
diff --git a/.github/workflows/app.yml b/.github/workflows/app.ymlindex 06408e1..f824be8 100644--- a/.github/workflows/app.yml+++ b/.github/workflows/app.yml@@ -107,6 +107,7 @@ jobs:make -s settingscheckmake -s routecheckmake -s bridgecheck+ make -s gamedrivecheckmake -s seedcheck- name: Run the Swift testsdiff --git a/Makefile b/Makefileindex be42eef..7138d9d 100644--- a/Makefile+++ b/Makefile@@ -64,7 +64,7 @@ DEPS := $(OBJS:.o=.d)tests-list overlay-shim overlay-shim-install overlay-shim-tests \overlay-shim-bench iconmaker icon \appinfo helpers-install ntdll-resolve bridge runcheck compatcheck \- compatsvc-check scriptcheck envcheck buildcheck settingscheck routecheck bridgecheck launch-shell FORCE+ compatsvc-check scriptcheck envcheck buildcheck settingscheck routecheck bridgecheck gamedrivecheck launch-shell FORCEAPP_PAYLOAD := app/Sources/NotProtonApp/Resources/payload@@ -116,6 +116,10 @@ bridgecheck:@if [ ! -f dylib/tests/bridgecheck.sh ]; then $(call SKIP,bridgecheck,dylib/tests/bridgecheck.sh); exit 0; fi; \sh dylib/tests/bridgecheck.sh dylib/feats/compat_run.sh+gamedrivecheck:+ @if [ ! -f dylib/tests/gamedrivecheck.sh ]; then $(call SKIP,gamedrivecheck,dylib/tests/gamedrivecheck.sh); exit 0; fi; \+ sh dylib/tests/gamedrivecheck.sh dylib/feats/compat_run.sh+# runcheck owns compat_run.sh, whose warnings wait for a change that can move# the embedded __text baselineSCRIPTS := $(shell git ls-files '*.sh' 2>/dev/null | grep -v '^dylib/feats/compat_run\.sh$$')diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.shindex 8831686..7c4aa08 100755--- a/dylib/feats/compat_run.sh+++ b/dylib/feats/compat_run.sh@@ -789,6 +789,56 @@ prepare_prefix_directory() {mkdir -p "$WINEPREFIX"}+# Like Proton, the game's Steam library gets drive S: so the game does not run from Z:.+map_game_drive() {+ drive="$WINEPREFIX/dosdevices/s:"+ owned="$STEAM_COMPAT_DATA_PATH/notproton-game-drive"+ [ -d "$WINEPREFIX/dosdevices" ] && [ ! -L "$WINEPREFIX/dosdevices" ] || return 0+ library=""+ set -f+ old_ifs=$IFS+ IFS=:+ for path in $STEAM_COMPAT_LIBRARY_PATHS; do+ path=${path%/}+ [ -n "$path" ] || continue+ case "$STEAM_COMPAT_INSTALL_PATH/" in+ "$path"/*) if [ "${#path}" -gt "${#library}" ]; then library=$path; fi ;;+ esac+ done+ IFS=$old_ifs+ set +f+ [ -n "$library" ] || return 0+ target=$library+ if real=$(cd -P -- "$library" 2>/dev/null && pwd) && [ "${real##*/}" = steamapps ]; then+ parent=${real%/*}+ if [ -n "$parent" ] && [ -w "$parent" ] \+ && [ "$(stat -f %d "$real")" = "$(stat -f %d "$parent")" ]; then+ target=$parent+ fi+ fi+ if [ -L "$drive" ]; then+ current=$(readlink "$drive") || return 0+ if [ "$current" = "$target" ]; then+ printf '%s\n' "$target" > "$owned" 2>/dev/null || true+ return 0+ fi+ if [ "$current" != "$(cat "$owned" 2>/dev/null)" ]; then+ echo "=== drive S: already points to $current, left in place ===" >> "$log" 2>&1 || true+ return 0+ fi+ rm -f "$drive" || return 0+ elif [ -e "$drive" ]; then+ echo "=== drive S: is not a link, left in place ===" >> "$log" 2>&1 || true+ return 0+ fi+ if ln -s "$target" "$drive" 2>> "$log"; then+ printf '%s\n' "$target" > "$owned" 2>/dev/null || true+ echo "=== mapped drive S: to $target ===" >> "$log" 2>&1 || true+ else+ echo "=== could not map drive S: to $target ===" >> "$log" 2>&1 || true+ fi+}+if [ -n "$STEAM_COMPAT_DATA_PATH" ]; thenexport WINEPREFIX="$STEAM_COMPAT_DATA_PATH/pfx"stage_step="prefix lock"@@ -820,6 +870,8 @@ if [ -n "$STEAM_COMPAT_DATA_PATH" ]; thenecho "video: RetinaMode=${NOTPROTON_RETINA:-0}" >> "$log" 2>&1 || truestage_step="prefix settings"import_prefix_settings+ stage_step="game drive"+ map_game_drivefibridge_src="$np_support/bridge"diff --git a/dylib/tests/gamedrivecheck.sh b/dylib/tests/gamedrivecheck.shnew file mode 100644index 0000000..fbeff1f--- /dev/null+++ b/dylib/tests/gamedrivecheck.sh@@ -0,0 +1,87 @@+#!/bin/sh+# shellcheck disable=SC2016 # the sh -ec program expands its own variables+set -e+SRC="${1:-$(dirname "$0")/../feats/compat_run.sh}"+[ -f "$SRC" ] || { echo "gamedrivecheck: $SRC not present, skipped"; exit 0; }++body=$(sed -n '/^map_game_drive() {/,/^}/p' "$SRC")+[ -n "$body" ] || { echo "FAIL: map_game_drive not found in $SRC"; exit 1; }++work=$(cd "$(mktemp -d)" && pwd -P)+trap 'rm -rf "$work"' EXIT++fails=0+ok() { printf ' ok %s\n' "$1"; }+bad() { printf ' FAIL %s\n want [%s]\n got [%s]\n' "$1" "$2" "$3"; fails=$((fails + 1)); }+is() { if [ "$2" = "$3" ]; then ok "$1"; else bad "$1" "$2" "$3"; fi; }++lib="$work/Steam Library/One"+other="$work/Other Library"+mkdir -p "$lib/steamapps/common/Some Game" "$lib/steamapps/compatdata/1/pfx/dosdevices" \+ "$other/steamapps/common/Some Game"+compat="$lib/steamapps/compatdata/1"+prefix="$compat/pfx"+drive="$prefix/dosdevices/s:"+libs="$work/elsewhere/steamapps:$lib/steamapps/"++run() {+ : > "$work/log"+ env WINEPREFIX="$prefix" STEAM_COMPAT_DATA_PATH="$compat" log="$work/log" body="$body" \+ STEAM_COMPAT_INSTALL_PATH="$1" STEAM_COMPAT_LIBRARY_PATHS="$2" \+ sh -ec 'eval "$body"; map_game_drive; echo reached' > "$work/out" 2>&1 || true+}+target() { readlink "$drive" 2>/dev/null || echo none; }++echo "== the library holding the game becomes S:"+run "$lib/steamapps/common/Some Game" "$libs"+is "S: points at the library root" "$lib" "$(target)"+is "the launch continues" reached "$(tail -1 "$work/out")"+is "the mapping is recorded" "$lib" "$(cat "$compat/notproton-game-drive")"++echo "== a second launch leaves it alone"+run "$lib/steamapps/common/Some Game" "$libs"+is "S: is unchanged" "$lib" "$(target)"+is "nothing is logged" "" "$(cat "$work/log")"++echo "== a moved game follows its library"+run "$other/steamapps/common/Some Game" "$libs:$other/steamapps"+is "S: points at the new library" "$other" "$(target)"++echo "== a user's own S: is kept"+rm -f "$drive"+ln -s /tmp "$drive"+run "$lib/steamapps/common/Some Game" "$libs"+is "S: still points at /tmp" /tmp "$(target)"+is "the launch continues" reached "$(tail -1 "$work/out")"++echo "== an S: folder is kept"+rm -f "$drive"+mkdir "$drive"+run "$lib/steamapps/common/Some Game" "$libs"+is "S: is still a folder" yes "$([ -d "$drive" ] && [ ! -L "$drive" ] && echo yes)"+rmdir "$drive"++echo "== a game outside every library gets no S:"+rm -f "$compat/notproton-game-drive"+run "$work/loose/Some Game" "$libs"+is "no S:" none "$(target)"+is "the launch continues" reached "$(tail -1 "$work/out")"++echo "== a library whose name only starts the same does not match"+run "$lib/steamapps2/common/Some Game" "$lib/steamapps"+is "no S:" none "$(target)"++echo "== a library path that is not a steamapps folder maps as is"+mkdir -p "$work/flat/common/Some Game"+run "$work/flat/common/Some Game" "$work/flat"+is "S: points at the library itself" "$work/flat" "$(target)"+rm -f "$drive"++echo "== a prefix without dosdevices is left for wine to build"+mv "$prefix/dosdevices" "$prefix/dosdevices.off"+run "$lib/steamapps/common/Some Game" "$libs"+is "no dosdevices created" no "$([ -e "$prefix/dosdevices" ] && echo yes || echo no)"+mv "$prefix/dosdevices.off" "$prefix/dosdevices"++[ "$fails" -eq 0 ] || { echo "gamedrivecheck: $fails failed"; exit 1; }+echo "gamedrivecheck: all passed"