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
Make games start about two seconds faster
Sharad Mayank Sinha78dae79ff124
diff --git a/.github/workflows/app.yml b/.github/workflows/app.ymlindex d060243..74bbaad 100644--- a/.github/workflows/app.yml+++ b/.github/workflows/app.yml@@ -103,6 +103,7 @@ jobs:make -s launch-shellmake -s envcheckmake -s buildcheck+ make -s settingscheckmake -s routecheck- name: Run the Swift testsdiff --git a/Makefile b/Makefileindex e1c8da7..308d51e 100644--- a/Makefile+++ b/Makefile@@ -61,7 +61,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 routecheck launch-shell FORCE+ compatsvc-check scriptcheck envcheck buildcheck settingscheck routecheck launch-shell FORCEAPP_PAYLOAD := app/Sources/NotProtonApp/Resources/payload@@ -96,6 +96,10 @@ buildcheck:@if [ ! -f dylib/tests/buildcheck.sh ]; then $(call SKIP,buildcheck,dylib/tests/buildcheck.sh); exit 0; fi; \sh dylib/tests/buildcheck.sh dylib/feats/compat_run.sh+settingscheck:+ @if [ ! -f dylib/tests/settingscheck.sh ]; then $(call SKIP,settingscheck,dylib/tests/settingscheck.sh); exit 0; fi; \+ sh dylib/tests/settingscheck.sh dylib/feats/compat_run.sh+routecheck:@if [ ! -f dylib/tests/routecheck.sh ]; then $(call SKIP,routecheck,dylib/tests/routecheck.sh); exit 0; fi; \sh dylib/tests/routecheck.sh dylib/feats/compat_run.shdiff --git a/app/Tests/NotProtonAppTests/PrefixToolsTests.swift b/app/Tests/NotProtonAppTests/PrefixToolsTests.swiftindex 6cf03f6..70e05ef 100644--- a/app/Tests/NotProtonAppTests/PrefixToolsTests.swift+++ b/app/Tests/NotProtonAppTests/PrefixToolsTests.swift@@ -1040,14 +1040,15 @@ struct PrefixToolsTests {let definition = try #require(source.range(of: "lay_out_proton_profile() {"))let call = try #require(source.range(of: " lay_out_proton_profile\n"))- let wineboot = try #require(source.range(of: "wineboot --init"))+ let settings = try #require(source.range(of: " import_prefix_settings\n"))// sh reads a script top to bottom, so a call above the definition is only an// unknown command.#expect(definition.lowerBound < call.lowerBound)// wineboot is what swaps the profile folders for links into the mac home, so- // they have to already exist when it runs.- #expect(call.lowerBound < wineboot.lowerBound)+ // they have to already exist when it runs. The settings import is the first+ // Wine process of a launch, and Wine runs wineboot --init ahead of it.+ #expect(call.lowerBound < settings.lowerBound)}@Test("The profile link points at steamuser, not out of the prefix")diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.shindex 9939def..1557ee0 100755--- a/dylib/feats/compat_run.sh+++ b/dylib/feats/compat_run.sh@@ -363,6 +363,37 @@ lay_out_proton_profile() {fi}+import_prefix_settings() {+ if [ "$NOTPROTON_RETINA" = "1" ]; then+ retina_line='"RetinaMode"="y"'+ else+ retina_line='"RetinaMode"=-'+ fi+ settings_file=$(mktemp "$WINEPREFIX/drive_c/notproton-settings.XXXXXX" 2>/dev/null) \+ || settings_file=""+ if [ -z "$settings_file" ] || ! printf '%s\r\n' \+ 'Windows Registry Editor Version 5.00' '' \+ '[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug]' '"Auto"="0"' '' \+ '[HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug]' '"Auto"="0"' '' \+ '[HKEY_CURRENT_USER\Software\Wine\WineDbg]' '"ShowCrashDialog"=dword:00000000' '' \+ '[HKEY_CURRENT_USER\Software\Wine\Mac Driver]' "$retina_line" '' \+ '[HKEY_LOCAL_MACHINE\Software\Classes\steam]' '"URL Protocol"=""' '' \+ '[HKEY_LOCAL_MACHINE\Software\Classes\steam\shell\open\command]' \+ '@="\"C:\\Program Files (x86)\\Steam\\steam.exe\" \"%1\""' '' \+ > "$settings_file" 2>/dev/null; then+ [ -z "$settings_file" ] || rm -f "$settings_file"+ echo "=== could not write the prefix settings, launching without them ===" >> "$log" 2>&1 || true+ # the bridge staging still needs a built prefix+ "$WINELOADER" wineboot --init >> "$log" 2>&1 || true+ return 0+ fi+ "$WINELOADER" reg import "C:\\${settings_file##*/}" >> "$log" 2>&1 \+ && import_status=0 || import_status=$?+ rm -f "$settings_file"+ [ "$import_status" -eq 0 ] \+ || echo "=== prefix settings import exited status=$import_status ===" >> "$log" 2>&1 || true+}+stage_step="runner check"if [ -z "$np_build" ] || [ ! -d "$CX_ROOT/lib/wine" ]; thenecho "=== build ${np_build:-(none recorded)} behind this compatibility tool is not set up, set it up in NotProton ===" >> "$log" 2>&1 || true@@ -393,20 +424,9 @@ if [ -n "$STEAM_COMPAT_DATA_PATH" ]; then"$WINESERVER" -k >> "$log" 2>&1 || truestage_step="profile layout"lay_out_proton_profile- "$WINELOADER" wineboot --init >> "$log" 2>&1 || true- "$WINELOADER" reg add 'HKLM\Software\Microsoft\Windows NT\CurrentVersion\AeDebug' /v Auto /t REG_SZ /d 0 /f >> "$log" 2>&1 || true- "$WINELOADER" reg add 'HKLM\Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug' /v Auto /t REG_SZ /d 0 /f >> "$log" 2>&1 || true- "$WINELOADER" reg add 'HKCU\Software\Wine\WineDbg' /v ShowCrashDialog /t REG_DWORD /d 0 /f >> "$log" 2>&1 || true-echo "video: RetinaMode=${NOTPROTON_RETINA:-0}" >> "$log" 2>&1 || true- if [ "$NOTPROTON_RETINA" = "1" ]; then- "$WINELOADER" reg add 'HKCU\Software\Wine\Mac Driver' /v RetinaMode /t REG_SZ /d y /f >> "$log" 2>&1 || true- else- "$WINELOADER" reg delete 'HKCU\Software\Wine\Mac Driver' /v RetinaMode /f >> "$log" 2>&1 || true- fi-- "$WINELOADER" reg add 'HKLM\Software\Classes\steam' /v 'URL Protocol' /t REG_SZ /d '' /f >> "$log" 2>&1 || true- "$WINELOADER" reg add 'HKLM\Software\Classes\steam\shell\open\command' /ve /t REG_SZ /d '"C:\Program Files (x86)\Steam\steam.exe" "%1"' /f >> "$log" 2>&1 || true+ stage_step="prefix settings"+ import_prefix_settingsfibridge_src="$np_support/bridge"@@ -482,15 +502,23 @@ bridge_files="$bridge_files lsteamclient.dll steam.exe"if [ -d "$bridge_src" ] && [ -n "$WINEPREFIX" ]; thenstage_step="bridge staging"mkdir -p "$prefix_steam"- for f in $bridge_files; do- src="$bridge_src/$f"- if [ ! -f "$src" ]; then- echo "=== bridge missing $f ===" >> "$log" 2>&1 || true- continue- fi- cp -f "$src" "$prefix_steam/$f" || \- echo "=== failed to stage $f ===" >> "$log" 2>&1- done+ # shellcheck disable=SC2086 # the list is ours and has no spaces+ src_stamp=$(cd "$bridge_src" && stat -f '%z %m' $bridge_files 2>/dev/null) || true+ # shellcheck disable=SC2086+ dst_stamp=$(cd "$prefix_steam" && stat -f '%z %m' $bridge_files 2>/dev/null) || true+ if [ -n "$src_stamp" ] && [ "$src_stamp" = "$dst_stamp" ]; then+ echo "=== bridge already staged ===" >> "$log" 2>&1 || true+ else+ for f in $bridge_files; do+ src="$bridge_src/$f"+ if [ ! -f "$src" ]; then+ echo "=== bridge missing $f ===" >> "$log" 2>&1 || true+ continue+ fi+ cp -fp "$src" "$prefix_steam/$f" || \+ echo "=== failed to stage $f ===" >> "$log" 2>&1+ done+ fifor f in "$prefix_steam"/*.dll "$prefix_steam"/*.so "$prefix_steam"/*.exe; do[ -f "$f" ] || continuecase " $bridge_files " in@@ -595,9 +623,11 @@ resolve_icon() {if [ -n "$meta_clienticon" ]; thenico="$loader_root/clienticon-$meta_clienticon.ico"absent="$loader_root/clienticon-$meta_clienticon.absent"+ failed="$loader_root/clienticon-$meta_clienticon.failed"find "$loader_root" -maxdepth 1 -name 'clienticon-*' ! -name "clienticon-$meta_clienticon.*" -delete 2>/dev/null || truefind "$absent" -mtime +14 -delete 2>/dev/null || true- if [ ! -s "$ico" ] && [ ! -f "$absent" ]; then+ find "$failed" -mmin +60 -delete 2>/dev/null || true+ if [ ! -s "$ico" ] && [ ! -f "$absent" ] && [ ! -f "$failed" ]; thenurl="https://shared.fastly.steamstatic.com/community_assets/images/apps/$app_id/$meta_clienticon.ico"code=$(curl -fsL --connect-timeout 5 --max-time 20 -w '%{http_code}' -o "$ico.new" "$url" 2>>"$log")magic=$(od -An -tx1 -N4 "$ico.new" 2>/dev/null | tr -d ' \n')@@ -610,7 +640,8 @@ resolve_icon() {: > "$absent"echo "no client icon published for $meta_clienticon" >> "$log" 2>&1 || trueelse- echo "client icon fetch for $meta_clienticon failed (http ${code:-none}), will retry" >> "$log" 2>&1 || true+ : > "$failed"+ echo "client icon fetch for $meta_clienticon failed (http ${code:-none}), will retry in an hour" >> "$log" 2>&1 || truefififidiff --git a/dylib/tests/settingscheck.sh b/dylib/tests/settingscheck.shnew file mode 100644index 0000000..c8e580d--- /dev/null+++ b/dylib/tests/settingscheck.sh@@ -0,0 +1,89 @@+#!/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 "settingscheck: $SRC not present, skipped"; exit 0; }++body=$(sed -n '/^import_prefix_settings() {$/,/^}$/p' "$SRC")+[ -n "$body" ] || { echo "FAIL: import_prefix_settings not found in $SRC"; exit 1; }++work=$(mktemp -d)+trap 'chmod -R u+w "$work"; rm -rf "$work"' EXIT++cat > "$work/wine" <<'EOF'+#!/bin/sh+printf '%s\n' "$*" >> "$FAKE_CALLS"+if [ "$1 $2" = "reg import" ]; then+ cp "$WINEPREFIX/drive_c/${3#C:\\}" "$FAKE_IMPORTED" 2>/dev/null || true+fi+exit "${FAKE_STATUS:-0}"+EOF+chmod +x "$work/wine"++settings() {+ printf '%s\r\n' 'Windows Registry Editor Version 5.00' '' \+ '[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug]' '"Auto"="0"' '' \+ '[HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug]' '"Auto"="0"' '' \+ '[HKEY_CURRENT_USER\Software\Wine\WineDbg]' '"ShowCrashDialog"=dword:00000000' '' \+ '[HKEY_CURRENT_USER\Software\Wine\Mac Driver]' "$1" '' \+ '[HKEY_LOCAL_MACHINE\Software\Classes\steam]' '"URL Protocol"=""' '' \+ '[HKEY_LOCAL_MACHINE\Software\Classes\steam\shell\open\command]' \+ '@="\"C:\\Program Files (x86)\\Steam\\steam.exe\" \"%1\""' ''+}+settings '"RetinaMode"=-' > "$work/retina-off"+settings '"RetinaMode"="y"' > "$work/retina-on"++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; }+same_file() { if cmp -s "$2" "$3"; then ok "$1"; else bad "$1" "contents of ${2##*/}" "$(cat -v "$3" 2>/dev/null)"; fi; }++case_dir=""+launch() {+ case_dir=$(mktemp -d "$work/case.XXXXXX")+ mkdir -p "$case_dir/pfx/drive_c"+ : > "$case_dir/calls"+ : > "$case_dir/log"+ [ "$3" != unwritable ] || chmod 500 "$case_dir/pfx/drive_c"+ env WINEPREFIX="$case_dir/pfx" WINELOADER="$work/wine" NOTPROTON_RETINA="$1" \+ FAKE_STATUS="$2" FAKE_CALLS="$case_dir/calls" FAKE_IMPORTED="$case_dir/imported" \+ log="$case_dir/log" body="$body" \+ sh -ec 'eval "$body"; import_prefix_settings; echo returned' \+ > "$case_dir/out" 2>&1 || true+ chmod 700 "$case_dir/pfx/drive_c"+}+calls() { sed 's/notproton-settings\.[A-Za-z0-9]*$/notproton-settings.X/' "$case_dir/calls"; }+leftovers() { find "$case_dir/pfx/drive_c" -name 'notproton-settings.*' | wc -l | tr -d ' '; }++echo "== one import per launch"+launch "" 0+is "Retina unset runs a single import and nothing else" 'reg import C:\notproton-settings.X' "$(calls)"+same_file "Retina unset deletes RetinaMode" "$work/retina-off" "$case_dir/imported"+is "the file is gone after the import" 0 "$(leftovers)"+is "a clean import logs nothing" "" "$(cat "$case_dir/log")"+is "the launch carries on" returned "$(cat "$case_dir/out")"++launch 1 0+same_file "Retina on sets RetinaMode to y" "$work/retina-on" "$case_dir/imported"++launch 0 0+same_file "Retina off deletes RetinaMode" "$work/retina-off" "$case_dir/imported"++echo "== failures"+launch "" 1+is "a failed import is logged" "=== prefix settings import exited status=1 ===" "$(cat "$case_dir/log")"+is "a failed import still removes the file" 0 "$(leftovers)"+is "a failed import does not end the launch" returned "$(cat "$case_dir/out")"++launch "" 0 unwritable+is "an unwritable C: drive falls back to wineboot, which builds the prefix" "wineboot --init" "$(calls)"+is "an unwritable C: drive is logged" "=== could not write the prefix settings, launching without them ===" "$(cat "$case_dir/log")"+is "an unwritable C: drive does not end the launch" returned "$(cat "$case_dir/out")"++if [ "$fails" -eq 0 ]; then+ echo "==> settingscheck: all assertions hold"+else+ echo "==> settingscheck: $fails failed"+ exit 1+fi