| 1 | # Build the Windows exe (no admin, no Visual Studio) |
| 2 | |
| 3 | Cross-compile from WSL with `cargo-xwin`. Verified 2026-10-07 on `spikes/gpui-list` (gpui-kit 0.7.1, gpui-pre-windows 0.3.8). |
| 4 | |
| 5 | ## Commands |
| 6 | |
| 7 | | Step | Command | |
| 8 | |---|---| |
| 9 | | Build spike | `scripts/build-windows.sh` | |
| 10 | | Build app | `scripts/build-windows.sh crates/app teams` (arg 2 = binary name) | |
| 11 | | Deploy app | `scripts/deploy-windows.sh`: copies the exe to `%LOCALAPPDATA%\Programs\ms-teams-linux\update\`. The running app swaps itself when idle, or on click in the status bar | |
| 12 | | Output | `<crate>/target/x86_64-pc-windows-msvc/release/<name>.exe` (`CARGO_TARGET_DIR` overrides, default `<crate>/target`) | |
| 13 | | Copy to Windows | `cp <exe> /mnt/c/Users/$USER/Desktop/` (never run from `\\wsl.localhost`) | |
| 14 | | Run | double-click, or `cmd.exe /c start "" C:\path\app.exe` | |
| 15 | | Screenshot (CI/agent) | `scripts/window-shot.ps1` (PrintWindow flag `2`). `CopyFromScreen` returns black | |
| 16 | |
| 17 | ## What the script does |
| 18 | |
| 19 | | Problem | Fix | |
| 20 | |---|---| |
| 21 | | No MSVC / Windows SDK | `cargo xwin` downloads CRT + SDK, `XWIN_ACCEPT_LICENSE=1` | |
| 22 | | `gpui-pre-windows/build.rs` skips shaders when the host is not Windows | Patched copy in `target/patched/`, injected with `--config patch.crates-io` | |
| 23 | | Needs `fxc.exe` (Windows SDK, needs admin) | `GPUI_FXC_PATH=scripts/fxc-wsl.sh`: runs `d3dcompiler_47.dll` (ships with Windows) via PowerShell | |
| 24 | | `gpui` build.rs needs `llvm-rc`, bundled sqlite needs `llvm-lib` | Symlink `llvm-rc-<ver>`, `llvm-lib-<ver>` as plain names on PATH | |
| 25 | |
| 26 | ## One-time setup |
| 27 | |
| 28 | | Need | Install | |
| 29 | |---|---| |
| 30 | | Rust + target | `rustup target add x86_64-pc-windows-msvc` (script does it) | |
| 31 | | `cargo-xwin` | `cargo install cargo-xwin --locked` (script does it) | |
| 32 | | `clang`, `llvm-rc`, `python3` | `sudo apt install clang llvm` (already present) | |
| 33 | | Windows side | Nothing. No Rust, no VS, no admin | |
| 34 | |
| 35 | ## Facts |
| 36 | |
| 37 | | Item | Value | |
| 38 | |---|---| |
| 39 | | Cold build | 3 min 04 s (xwin download of CRT + SDK included, cached in `~/.cache/cargo-xwin`) | |
| 40 | | Exe size | 23 MB (release) | |
| 41 | | Cargo feature | None needed. `gpui` default `windows-manifest` works with `llvm-rc` | |
| 42 | | Shaders | Compiled at build time (release only). Debug builds read `shaders.hlsl` from the build path at runtime: do not ship debug | |
| 43 | | Fonts | Windows system fonts. Bold renders (unlike WSLg) | |
| 44 | | Renderer | DirectX 11 | |
| 45 | |
| 46 | ## Fails if |
| 47 | |
| 48 | | Symptom | Cause | |
| 49 | |---|---| |
| 50 | | `Failed to find fxc.exe` | `GPUI_FXC_PATH` unset: run through the script | |
| 51 | | `NotAttempted("llvm-rc")` | No `llvm-rc` installed | |
| 52 | | `failed to find tool "llvm-lib"` | No `llvm-lib` installed (`sudo apt install llvm`) | |
| 53 | | Black screenshot | Wrong capture API, window is fine | |
| 54 | | Powershell cannot find the shim | WSL interop disabled | |
| 55 | |
| 56 | ## UI font (Google Sans Flex, OFL 1.1) |
| 57 | |
| 58 | | Item | Value | |
| 59 | |---|---| |
| 60 | | Source | `github.com/google/fonts` -> `ofl/googlesansflex/GoogleSansFlex[GRAD,ROND,opsz,slnt,wdth,wght].ttf` + `OFL.txt` | |
| 61 | | Embedded | `crates/app/assets/fonts/GoogleSansFlex-{Regular,SemiBold,Bold,Italic}.ttf`, loaded in `theme::load_fonts` | |
| 62 | | Why static | The variable font is not used: static instances switch weights reliably under DirectWrite | |
| 63 | | Regenerate | `python3 scripts/font-instances.py <variable.ttf> crates/app/assets/fonts` (needs `pip install fonttools`) | |
| 64 | | Pinned axes | wght 400/600/700, wdth 100, opsz 14, GRAD 0, ROND 0, slnt 0 (Italic: -10) | |
| 65 | | Not used | Plain "Google Sans" is not openly licensed | |
| 66 | | Code blocks | Cascadia Code, else Consolas | |
| 67 | |
| 68 | ## Frame log (perf debugging) |
| 69 | |
| 70 | | Item | Value | |
| 71 | |---|---| |
| 72 | | Enable | Set `RUSTY_TEAMS_FRAME_LOG=<file>` before starting the exe (`--demo` for tests) | |
| 73 | | Output | First line: GPU adapter. Then once per second: draws, longest gap, prepaint-to-paint mean/max | |
| 74 | | Idle baseline | 2 draws/s (caret blink) | |
| 75 | | Window drag | Every WM_MOVE forces a full uncached redraw in gpui-pre. Cost per frame must stay flat in chat count | |