Skip to content

Commit

Permalink
optional git
Browse files Browse the repository at this point in the history
  • Loading branch information
yihozhang committed Sep 26, 2024
1 parent 5bf9dee commit f86182e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use std::{env, process::Command};
#[allow(clippy::disallowed_macros)] // for println!
fn main() {
lalrpop::process_root().unwrap();
let output = Command::new("git")
let git_hash = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap();
.map(|output| String::from_utf8(output.stdout).unwrap_or_default())
.unwrap_or_default();
let build_date = chrono::Utc::now().format("%Y-%m-%d");
let version = env::var("CARGO_PKG_VERSION").unwrap();
let full_version = format!("{}_{}_{}", version, build_date, git_hash);
let full_version = format!("{}_{}{}", version, build_date, git_hash);
println!("cargo:rustc-env=FULL_VERSION={}", full_version);
}

0 comments on commit f86182e

Please sign in to comment.