Files
proxy-suite-flake/windows/crates/ps-gui/build.rs
T
faumarayandClaude Opus 5.5 ae31e499ca windows: the app's whitelist-bypass page, and its icon
A page for whitelist-bypass: on or off; joiners with their state and the
call link to join; creators with theirs, their call link to copy, a new
call, and their login (a cookies export picked from disk, or DION's and
Bitrix's email and password); adding and removing either.

The app carries an icon now (tools/make-icon.py draws it; llvm-rc makes
it the exe's resource 1, where GPUI, Explorer and the Start Menu take it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:21:49 +03:00

34 lines
1.7 KiB
Rust

//! The Windows build carries the app's icon as its resource 1, where GPUI loads its windows'
//! icon from (and Explorer, the Start Menu and Settings > Apps show it). The resource compiler
//! is LLVM's (`llvm-rc`, in the dev shell; `RC` names another); without one the app builds
//! with Windows' default icon, and says so.
use std::path::PathBuf;
use std::process::Command;
fn main() {
let icon = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("assets/proxy-suite.ico");
println!("cargo:rerun-if-changed={}", icon.display());
println!("cargo:rerun-if-env-changed=RC");
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") {
return;
}
let out = PathBuf::from(std::env::var("OUT_DIR").unwrap());
let rc = out.join("app.rc");
let res = out.join("app.res");
// The resource script's strings are C strings: backslashes doubled.
std::fs::write(&rc, format!("1 ICON \"{}\"\n", icon.display().to_string().replace('\\', "\\\\"))).unwrap();
let compiler = std::env::var("RC").unwrap_or_else(|_| if cfg!(windows) { "rc.exe".into() } else { "llvm-rc".into() });
let mut command = Command::new(&compiler);
command.arg("/nologo");
if compiler.contains("llvm-rc") {
// Nothing to preprocess, so no C compiler needed for it.
command.arg("/no-preprocess");
}
match command.arg("/fo").arg(&res).arg(&rc).status() {
Ok(s) if s.success() => println!("cargo:rustc-link-arg-bins={}", res.display()),
Ok(s) => println!("cargo:warning=the app's icon: {compiler} failed ({s}); building without it"),
Err(e) => println!("cargo:warning=the app's icon: no {compiler} ({e}); building without it"),
}
}