- Tray (gpui-tray): a shield coloured by how things are (working, one failed, all off, no service), its tooltip saying which; the menu opens the window and switches the local proxy, the DPI bypass and the Telegram proxy, with their states checked; Quit. Closing the window leaves the app in the tray (no tray: it quits); --hidden starts it there. - The app builds for Windows from Linux: GPUI compiles its HLSL shaders with fxc.exe only when the building machine is Windows, so its Windows backend is vendored with that one check made on the target instead (vendor/gpui-pre-windows/PATCHED.md, tools/vendor-gpui-windows.py), and tools/fxc-wine.sh runs Microsoft's fxc.exe under Wine: the compiler from the Windows SDK 10.0.26100 installer, pinned by hash, kept on the build machine; only the compiled shaders go into the app. - gui-shot.sh keeps the app off the desktop's session bus. Under Wine the app starts but cannot draw text (Wine's DirectWrite does not implement font-set matching), so its Windows rendering is untested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
81 lines
3.5 KiB
Python
81 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
|
"""GPUI's Windows backend, vendored with its build script patched, into vendor/gpui-pre-windows.
|
|
|
|
Upstream compiles the HLSL shaders (with fxc.exe) only when the machine building is Windows:
|
|
its build script asks `cfg!(target_os = "windows")`, which in a build script is the host.
|
|
Cross-compiled from Linux, the release library then fails for want of the compiled shaders.
|
|
The patch asks the target instead (CARGO_CFG_TARGET_OS, CARGO_CFG_DEBUG_ASSERTIONS) and lets
|
|
GPUI_FXC_PATH name any program that acts as fxc.exe (tools/fxc-wine.sh runs it under Wine).
|
|
Nothing else changes.
|
|
|
|
python3 -I tools/vendor-gpui-windows.py ~/.cargo/registry/src/*/gpui-pre-windows-0.3.10
|
|
"""
|
|
|
|
import shutil
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
src = Path(sys.argv[1])
|
|
dst = Path(__file__).resolve().parent.parent / "vendor" / "gpui-pre-windows"
|
|
shutil.rmtree(dst, ignore_errors=True)
|
|
shutil.copytree(src, dst, ignore=shutil.ignore_patterns(".cargo-ok", ".cargo_vcs_info.json", "Cargo.toml.orig", "Cargo.lock"))
|
|
|
|
build = (dst / "build.rs").read_text()
|
|
|
|
|
|
def replace(old: str, new: str) -> None:
|
|
global build
|
|
if build.count(old) != 1:
|
|
sys.exit(f"build.rs has changed upstream; update the patch: {old[:60]!r}")
|
|
build = build.replace(old, new)
|
|
|
|
|
|
main_start = build.index("fn main() {")
|
|
main_end = build.index("\n}\n", main_start) + 3
|
|
build = (
|
|
build[:main_start]
|
|
+ '''// Patched for Proxy Suite (tools/vendor-gpui-windows.py): the shaders are compiled when the
|
|
// target is Windows in a release build, whatever machine builds it.
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
println!("cargo:rerun-if-env-changed=GPUI_FXC_PATH");
|
|
let windows = std::env::var("CARGO_CFG_TARGET_OS").is_ok_and(|os| os == "windows");
|
|
let release = std::env::var_os("CARGO_CFG_DEBUG_ASSERTIONS").is_none();
|
|
if windows && release {
|
|
shader_compilation::compile_shaders();
|
|
}
|
|
}
|
|
'''
|
|
+ build[main_end:]
|
|
)
|
|
replace('#[cfg(all(target_os = "windows", not(debug_assertions)))]\nmod shader_compilation {', "mod shader_compilation {")
|
|
replace(" pub fn find_latest_windows_sdk_binary(", " #[cfg(windows)]\n pub fn find_latest_windows_sdk_binary(")
|
|
replace(
|
|
""" // Try to find in PATH
|
|
// NOTE: This has to be `where.exe` on Windows, not `where`, it must be ended with `.exe`
|
|
if let Ok(output)""",
|
|
""" // Try to find in PATH
|
|
// NOTE: This has to be `where.exe` on Windows, not `where`, it must be ended with `.exe`
|
|
#[cfg(windows)]
|
|
if let Ok(output)""",
|
|
)
|
|
replace(
|
|
""" if let Ok(Some(path)) = find_latest_windows_sdk_binary("fxc.exe") {""",
|
|
""" #[cfg(windows)]
|
|
if let Ok(Some(path)) = find_latest_windows_sdk_binary("fxc.exe") {""",
|
|
)
|
|
replace(' panic!("Failed to find fxc.exe");', ' panic!("Failed to find fxc.exe (cross-compiling, set GPUI_FXC_PATH: tools/fxc-wine.sh)");')
|
|
replace('#[cfg(all(target_os = "windows", not(debug_assertions)))]\nuse shader_compilation::compile_shaders;\n', "")
|
|
(dst / "build.rs").write_text(build)
|
|
|
|
(dst / "PATCHED.md").write_text(
|
|
f"""# gpui-pre-windows, patched
|
|
|
|
`{src.name}` from crates.io (Apache-2.0, LICENSE-APACHE), unchanged except `build.rs`: the HLSL
|
|
shaders are compiled when the target (not the building machine) is Windows in a release build,
|
|
and GPUI_FXC_PATH may name any program acting as fxc.exe. Made by
|
|
`tools/vendor-gpui-windows.py`; the workspace uses it through `[patch.crates-io]`.
|
|
"""
|
|
)
|
|
print(f"vendored {src.name} into {dst}")
|