Skip to content

Commit

Permalink
use winres to set application icon on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
GyulyVGC committed Feb 16, 2025
1 parent 39b3ac4 commit 88da289
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include = [
"/resources/DB/*.mmdb",
"/resources/fonts/subset/*.ttf",
"/resources/logos/raw/icon.png",
"/resources/packaging/windows/graphics/sniffnet.ico",
"/resources/sounds/*.mp3",
"/services.txt",
"/build.rs",
Expand Down Expand Up @@ -80,6 +81,9 @@ phf_shared = "0.11.3"
rustrict = { version = "0.7.33", default-features = false, features = ["censor"] }
once_cell = "1.20.3"

[target."cfg(windows)".build-dependencies]
winres = "0.1.12"

#═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════

[badges]
Expand Down
13 changes: 13 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(windows)]
extern crate winres;

use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader, BufWriter, Write};
Expand All @@ -16,9 +19,19 @@ fn main() {
println!("cargo:rerun-if-changed={WINDOWS_ICON_PATH}");
println!("cargo:rerun-if-changed={SERVICES_LIST_PATH}");

set_icon();
build_services_phf();
}

fn set_icon() {
#[cfg(windows)]
{
let mut res = winres::WindowsResource::new();
res.set_icon(WINDOWS_ICON_PATH);
res.compile().unwrap();
}
}

fn build_services_phf() {
let out_path = Path::new(&env::var("OUT_DIR").unwrap()).join("services.rs");
let mut output = BufWriter::new(File::create(out_path).unwrap());
Expand Down

0 comments on commit 88da289

Please sign in to comment.