Skip to content

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

Initialize bundled Apple GPTK support for CrossOver launches

Rajan Singh5f2562012238
diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.sh
index 48ec625..eed71af 100755
--- a/dylib/feats/compat_run.sh
+++ b/dylib/feats/compat_run.sh
@@ -37,6 +37,10 @@ np_display=$(sed -n 's/.*"display_name"[[:space:]]*"\(.*\)".*/\1/p' \
[ -n "$np_display" ] || np_display="CrossOver build ${np_build:-unknown}"
CX_ROOT="$np_support/runners/crossover-$np_build/CrossOver"
export CX_ROOT
+# CrossOver initializes Rosetta's Windows thread-state support even without D3DMetal.
+if [ -f "$CX_ROOT/lib64/apple_gptk/external/libd3dshared.dylib" ]; then
+ export CX_APPLEGPTK_LIBD3DSHARED_PATH="$CX_ROOT/lib64/apple_gptk/external/libd3dshared.dylib"
+fi
wine_unix="$CX_ROOT/lib/wine/aarch64-unix"
WINELOADER="$wine_unix/wine.app/Contents/MacOS/wine"
@@ -1355,7 +1359,7 @@ else
echo "=== client staged no overlay renderer, overlay disabled ===" >> "$log" 2>&1 || true
fi
set -- --args "$shim_exe" "$@"
-for name in $(env | sed -nE 's/^(Steam[A-Za-z0-9]*|(CX_GRAPHICS|D3DM_|DXMT_|DXVK_|MTL_|ROSETTA_)[A-Z0-9_]*)=.*/\1/p'); do
+for name in $(env | sed -nE 's/^(CX_APPLEGPTK_LIBD3DSHARED_PATH|Steam[A-Za-z0-9]*|(CX_GRAPHICS|D3DM_|DXMT_|DXVK_|MTL_|ROSETTA_)[A-Z0-9_]*)=.*/\1/p'); do
eval "value=\$$name"
# shellcheck disable=SC2154 # eval assigns value on the line above
set -- --env "$name=$value" "$@"
diff --git a/dylib/tests/envcheck.sh b/dylib/tests/envcheck.sh
index e75b40c..a7ae692 100755
--- a/dylib/tests/envcheck.sh
+++ b/dylib/tests/envcheck.sh
@@ -36,6 +36,32 @@ WINEDLLOVERRIDES="lsteamclient=n"
eval "$overrides_line"
is "trio outranks user" "lsteamclient=n;steamclient=n;steamclient64=n;lsteamclient=b" "$WINEDLLOVERRIDES"
+echo "== Apple GPTK initialization and launcher environment =="
+work=$(mktemp -d)
+trap 'rm -rf "$work"' EXIT
+np_support="$work/Application Support/notproton"
+np_build="test"
+library="$np_support/runners/crossover-$np_build/CrossOver/lib64/apple_gptk/external/libd3dshared.dylib"
+init=$(sed -n '/^CX_ROOT=/,/^wine_unix=/p' "$SRC")
+# shellcheck disable=SC2016 # Match the literal launcher loop.
+forward=$(sed -n '/^for name in $(env /,/^done$/p' "$SRC")
+[ -n "$init" ] && [ -n "$forward" ] || { echo "FAIL: runner environment blocks not found"; exit 1; }
+unset CX_APPLEGPTK_LIBD3DSHARED_PATH
+eval "$init"
+is "runner without the library leaves the path unset" "" "${CX_APPLEGPTK_LIBD3DSHARED_PATH:-}"
+mkdir -p "$(dirname "$library")"
+: > "$library"
+eval "$init"
+is "bundled library is selected" "$library" "${CX_APPLEGPTK_LIBD3DSHARED_PATH:-}"
+is "helpers inherit the library path" "$library" "$(sh -c 'printf %s "$CX_APPLEGPTK_LIBD3DSHARED_PATH"')"
+set --
+eval "$forward"
+forwarded=""
+for arg in "$@"; do
+ case "$arg" in CX_APPLEGPTK_LIBD3DSHARED_PATH=*) forwarded=${arg#*=} ;; esac
+done
+is "game launcher receives the path as one argument" "$library" "$forwarded"
+
if [ "$fails" -eq 0 ]; then
echo "==> envcheck: all assertions hold"
else