diff --git a/.cargo/config.toml b/.cargo/config.toml index f11910bc..1fb3555c 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -9,9 +9,5 @@ # ``` # and checking that the output doesn't contain any MSVCR DLLs -[target.'cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc")'] -rustflags = [ - "-Ctarget-feature=+crt-static", - "-L./icon", - "-Clink-args=resources.res", -] +[target.x86_64-pc-windows-msvc] +rustflags = ["-Ctarget-feature=+crt-static"] diff --git a/cli/build.rs b/cli/build.rs new file mode 100644 index 00000000..b759c36b --- /dev/null +++ b/cli/build.rs @@ -0,0 +1,21 @@ +use std::{env, error, fs}; + +fn link_icon() -> Result<(), Box> { + if env::var("TARGET")? == "x86_64-pc-windows-msvc" { + println!("cargo::rerun-if-changed=../icon/resources.res"); + if fs::exists("../icon/resources.res")? { + println!("cargo::rustc-link-arg-bins=icon/resources.res"); + } else { + return Err( + "could not find `resources.res` file; fend will not have an app icon".into(), + ); + } + } + Ok(()) +} + +fn main() { + if let Err(e) = link_icon() { + println!("cargo::warning={e}"); + } +}