From 5c68b550678601a9646e0c44e617069ee16db348 Mon Sep 17 00:00:00 2001 From: pml68 Date: Wed, 26 Feb 2025 23:23:52 +0100 Subject: feat: switch to personal `iced` fork, work on version info --- build.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'build.rs') diff --git a/build.rs b/build.rs index 438ce37..5b868a4 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,17 @@ +use std::process::Command; + fn main() { + let git_hash = Command::new("git") + .args(["describe", "--always", "--dirty", "--exclude='*'"]) + .output() + .ok() + .filter(|output| output.status.success()) + .and_then(|x| String::from_utf8(x.stdout).ok()); + + if let Some(hash) = git_hash.as_ref() { + println!("cargo:rustc-env=GIT_HASH={}", hash); + } + println!("cargo::rerun-if-changed=fonts/icons.toml"); iced_fontello::build("fonts/icons.toml").expect("Build icons font"); #[cfg(windows)] -- cgit v1.2.3 From 0b8e2d4570cecf3bae2273b9882f48815acffa6c Mon Sep 17 00:00:00 2001 From: pml68 Date: Mon, 3 Mar 2025 23:49:03 +0100 Subject: fix: build.rs not running on git changes --- build.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'build.rs') diff --git a/build.rs b/build.rs index 5b868a4..d1a02af 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,7 @@ +// (c) 2023 Cory Forsstrom +// (c) 2024-2025 Polesznyák Márk László + +use std::path::Path; use std::process::Command; fn main() { @@ -12,6 +16,39 @@ fn main() { println!("cargo:rustc-env=GIT_HASH={}", hash); } + if git_hash.is_none() { + return; + } + + let Some(git_dir): Option = Command::new("git") + .args(["rev-parse", "--git-dir"]) + .output() + .ok() + .filter(|output| output.status.success()) + .and_then(|x| String::from_utf8(x.stdout).ok()) + else { + return; + }; + + let head = Path::new(&git_dir).join("HEAD"); + if head.exists() { + println!("cargo:rerun-if-changed={}", head.display()); + } + + let Some(head_ref): Option = Command::new("git") + .args(["symbolic-ref", "HEAD"]) + .output() + .ok() + .filter(|output| output.status.success()) + .and_then(|x| String::from_utf8(x.stdout).ok()) + else { + return; + }; + let head_ref = Path::new(&git_dir).join(head_ref); + if head_ref.exists() { + println!("cargo:rerun-if-changed={}", head_ref.display()); + } + println!("cargo::rerun-if-changed=fonts/icons.toml"); iced_fontello::build("fonts/icons.toml").expect("Build icons font"); #[cfg(windows)] -- cgit v1.2.3