Files
proxy-suite-flake/windows/tools/fxc-wine.sh
T
faumarayandClaude Opus 5.5 ddc1bbe686 windows: fxc's download retried and resumable, as the other pinned downloads
The release build failed on one connection reset fetching the SDK cab that
fxc.exe comes from: fxc-wine.sh now uses lib.sh's fetch_pinned (hash
checked, in pieces when the line stalls), whose whole-file attempt now
retries on any error, a reset included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 00:07:59 +03:00

49 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# fxc.exe, Microsoft's HLSL compiler, under Wine: GPUI's shaders, when the app is cross-compiled
# for Windows (GPUI_FXC_PATH names this; see tools/vendor-gpui-windows.py). The compiler comes
# from the Windows SDK 10.0.26100 that Visual Studio's installer offers, pinned by hash, and
# stays on this machine: only the shaders it compiles go into the app.
#
# GPUI_FXC_PATH=$PWD/tools/fxc-wine.sh cargo xwin build --release -p ps-gui --target x86_64-pc-windows-msvc
set -euo pipefail
CACHE=${XDG_CACHE_HOME:-$HOME/.cache}/proxy-suite-windows/fxc-10.0.26100
CAB_URL=https://download.visualstudio.microsoft.com/download/pr/6452c1f1-dc1e-413c-8b19-991b61870a8b/944d105a33e16da614cbf2a17da22954/69661e20556b3ca9456b946c2c881ddd.cab
CAB_SHA256=bef5b038fce288fa1db234bd61c3e450abecc02f5a386248625073a83010f61e
FXC_SHA256=31fa10504b1551337de4d06ec2194143885a76a8b5a81177999e2faa34729183
DLL_SHA256=2b23efdc8b45adc4b79c1c0b940a906336628cd35ed80defd489d70d22ff6d74
# Their names in the cab: the File table of "Windows SDK for Windows Store Apps Tools", bin/10.0.26100.0/x64.
FXC_IN_CAB=fil6dfaf6bbf56939fbab75b569ffa0fd41
DLL_IN_CAB=fil0d3f984977487cd87127d614f654195b
here=$(dirname "$(realpath "$0")")
. "$here/lib.sh"
pkg() { nix build --no-link --print-out-paths --inputs-from "$here/.." "nixpkgs#$1" | head -1; }
verified() {
[ -f "$CACHE/fxc.exe" ] && [ -f "$CACHE/d3dcompiler_47.dll" ] &&
echo "$FXC_SHA256 $CACHE/fxc.exe" | sha256sum -c --quiet 2>/dev/null &&
echo "$DLL_SHA256 $CACHE/d3dcompiler_47.dll" | sha256sum -c --quiet 2>/dev/null
}
if ! verified; then
mkdir -p "$CACHE"
tmp=$(mktemp -d)
# Retried, and in pieces if the line stalls (a reset failed a release build once).
fetch_pinned "$CAB_URL" "$CAB_SHA256" "$tmp/tools.cab" >&2
(cd "$tmp" && "$(pkg gcab.bin)/bin/gcab" -x tools.cab "$FXC_IN_CAB" "$DLL_IN_CAB")
mv "$tmp/$FXC_IN_CAB" "$CACHE/fxc.exe"
mv "$tmp/$DLL_IN_CAB" "$CACHE/d3dcompiler_47.dll"
rm -rf "$tmp"
verified || { echo "fxc-wine.sh: the extracted compiler does not match its hashes" >&2; exit 1; }
fi
WINE=$(pkg wineWow64Packages.stable)/bin
export WINEPREFIX=$CACHE/wine WINEDEBUG=-all WINEDLLOVERRIDES="mscoree,mshtml="
[ -d "$WINEPREFIX" ] || "$WINE/wineboot" -i >/dev/null 2>&1 || true
# Unix paths (the shader sources, the headers it writes) as Wine's Z: paths; a lone /X is a switch.
args=()
for a in "$@"; do
if [[ $a == /*/* ]]; then args+=("$("$WINE/winepath" -w "$a")"); else args+=("$a"); fi
done
exec "$WINE/wine" "$CACHE/fxc.exe" "${args[@]}"