Skip to content

Commit

Permalink
About dialog: Fix build error when no git repository is present
Browse files Browse the repository at this point in the history
  • Loading branch information
crumblingstatue committed Feb 13, 2023
1 parent b6ba424 commit 0676b09
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
7 changes: 5 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use vergen::{vergen, Config};

fn main() {
// Generate the default 'cargo:' instruction output
vergen(Config::default()).unwrap();
let mut vergen_cfg = Config::default();
*vergen_cfg.git_mut().skip_if_error_mut() = true;
if let Err(e) = vergen(vergen_cfg) {
println!("cargo:warning=Vergen failed with error: {e}");
}
}
20 changes: 13 additions & 7 deletions src/gui/windows/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ pub struct AboutWindow {

const MIB: u64 = 1_048_576;

macro_rules! optenv {
($name:literal) => {
option_env!($name).unwrap_or("<unavailable>").to_string()
};
}

impl AboutWindow {
pub fn ui(ui: &mut egui::Ui, gui: &mut Gui, app: &mut App) {
let win = &mut gui.about_window;
Expand All @@ -33,27 +39,27 @@ impl AboutWindow {
.unwrap_or_else(|| "Unknown version".into());
win.info = [
("Hexerator", String::new()),
("Version", env!("VERGEN_GIT_SEMVER").into()),
("Git SHA", env!("VERGEN_GIT_SHA").into()),
("Version", optenv!("CARGO_PKG_VERSION")),
("Git SHA", optenv!("VERGEN_GIT_SHA")),
(
"Commit date",
env!("VERGEN_GIT_COMMIT_TIMESTAMP")
optenv!("VERGEN_GIT_COMMIT_TIMESTAMP")
.split('T')
.next()
.unwrap_or("error")
.into(),
),
(
"Build date",
env!("VERGEN_BUILD_TIMESTAMP")
optenv!("VERGEN_BUILD_TIMESTAMP")
.split('T')
.next()
.unwrap_or("error")
.into(),
),
("Target", env!("VERGEN_CARGO_TARGET_TRIPLE").into()),
("Cargo profile", env!("VERGEN_CARGO_PROFILE").into()),
("Built with rustc", env!("VERGEN_RUSTC_SEMVER").into()),
("Target", optenv!("VERGEN_CARGO_TARGET_TRIPLE")),
("Cargo profile", optenv!("VERGEN_CARGO_PROFILE")),
("Built with rustc", optenv!("VERGEN_RUSTC_SEMVER")),
("System", String::new()),
("OS", format!("{system_name} {os_ver}")),
("CPU", win.sys.global_cpu_info().brand().into()),
Expand Down

0 comments on commit 0676b09

Please sign in to comment.