Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

feat(run): let a launch option set any environment variable for the game

Nathaniel Brownab3c2fc60b19
diff --git a/Makefile b/Makefile
index 27fe25d..0998dcf 100644
--- a/Makefile
+++ b/Makefile
@@ -143,7 +143,8 @@ bridgecheck:
sh dylib/tests/bridgecheck.sh dylib/feats/compat_run.sh
envpasscheck:
- @if [ ! -f dylib/tests/envpasscheck.sh ]; then $(call SKIP,envpasscheck,dylib/tests/envpasscheck.sh); exit 0; fi; \
+ @if [ ! -f dylib/tests/envpasscheck.sh ]; then \
+ $(call SKIP,envpasscheck,dylib/tests/envpasscheck.sh); exit 0; fi; \
sh dylib/tests/envpasscheck.sh dylib/feats/compat_run.sh
prefixnotecheck:
diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.sh
index 1bb0537..4b1c4ff 100755
--- a/dylib/feats/compat_run.sh
+++ b/dylib/feats/compat_run.sh
@@ -2829,20 +2829,18 @@ done
# Anything this script does not know by name. A launch option NOTPROTON_ENV_FOO=bar gives
# the game FOO=bar, which is the only per-game way to set one, and Wine and the graphics
# layers take far more than the prefixes above.
-np_env_reserved="CX_ROOT CX_HOME HOME PATH WINEPREFIX WINELOADER WINESERVER WINEDLLPATH \
-WINEDLLOVERRIDES STEAM_COMPAT_DATA_PATH STEAM_COMPAT_INSTALL_PATH NOTPROTON_GAME_CWD \
-STEAM_COMPAT_CLIENT_INSTALL_PATH STEAM_COMPAT_APP_ID STEAM_DYLD_INSERT_LIBRARIES"
np_env_passed=$(env | LC_ALL=C sed -nE 's/^NOTPROTON_ENV_([A-Za-z_][A-Za-z0-9_]*)=.*/\1/p' \
| LC_ALL=C sort)
for name in $np_env_passed; do
- case " $np_env_reserved " in
- *" $name "*)
+ case "$name" in
+ (DYLD_* | PATH | HOME | CX_ROOT | CX_HOME | STEAM_COMPAT_* | STEAM_DYLD_INSERT_LIBRARIES | \
+ WINEPREFIX | WINELOADER | WINESERVER | WINEDLLPATH | WINEDLLOVERRIDES | WINEMSYNC | NOTPROTON_* | \
+ BRIDGEPLAY_*)
echo "=== NOTPROTON_ENV_$name would replace a setting this launch sets itself, ignored ===" \
>> "$log" 2>&1 || true
continue ;;
esac
eval "value=\$NOTPROTON_ENV_$name"
- export "$name=$value"
set -- --env "$name=$value" "$@"
echo "=== NOTPROTON_ENV_$name sets $name ===" >> "$log" 2>&1 || true
done
diff --git a/dylib/tests/envpasscheck.sh b/dylib/tests/envpasscheck.sh
index dbaeb5a..d0986d7 100755
--- a/dylib/tests/envpasscheck.sh
+++ b/dylib/tests/envpasscheck.sh
@@ -5,7 +5,7 @@ set -e
SRC="${1:-$(dirname "$0")/../feats/compat_run.sh}"
[ -f "$SRC" ] || { echo "envpasscheck: $SRC not present, skipped"; exit 0; }
-block=$(sed -n '/^np_env_reserved=/,/^done$/p' "$SRC")
+block=$(sed -n '/^np_env_passed=/,/^done$/p' "$SRC")
case "$block" in
*NOTPROTON_ENV_*) ;;
*) echo "FAIL: the passthrough loop was not found in $SRC"; exit 1 ;;
@@ -38,9 +38,15 @@ ok "an empty value is still passed" "$(forwarded NOTPROTON_ENV_EMPTY=)" "EMPTY=
# The launch sets these itself; letting a game replace them breaks it in ways that look
# like NotProton is at fault.
-for reserved in CX_ROOT WINEPREFIX PATH STEAM_DYLD_INSERT_LIBRARIES WINEDLLOVERRIDES; do
+for reserved in CX_ROOT WINEPREFIX PATH HOME STEAM_DYLD_INSERT_LIBRARIES STEAM_COMPAT_APP_ID \
+ WINEDLLOVERRIDES WINEMSYNC DYLD_INSERT_LIBRARIES DYLD_LIBRARY_PATH NOTPROTON_FEATURE_DYLIBS \
+ NOTPROTON_GAME_CWD; do
ok "$reserved is refused" "$(forwarded "NOTPROTON_ENV_$reserved=x")" ""
done
+ok "Wine's own settings still pass" \
+ "$(forwarded NOTPROTON_ENV_WINEDEBUG=+loaddll NOTPROTON_ENV_WINEESYNC=1)" "WINEDEBUG=+loaddll WINEESYNC=1 "
+ok "a name the script uses itself reaches the game as given" \
+ "$(forwarded NOTPROTON_ENV_name=HELLO NOTPROTON_ENV_log=x)" "log=x name=HELLO "
ok "a refusal does not stop the rest" \
"$(forwarded NOTPROTON_ENV_CX_ROOT=x NOTPROTON_ENV_KEEP=yes)" "KEEP=yes "