Skip to content

Commit

Permalink
Merge pull request #427 from egraphs-good/build-info
Browse files Browse the repository at this point in the history
Display build info when running egglog
  • Loading branch information
yihozhang authored Sep 28, 2024
2 parents 8d9b10e + 821cfb5 commit c5fa39d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ im-rc = "15.1.0"

[build-dependencies]
lalrpop = "0.20"
chrono = { version = "0.4", default-features = false, features = ["now"] }

[dev-dependencies]
glob = "0.3.1"
Expand Down
16 changes: 16 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
use std::{env, process::Command};

#[allow(clippy::disallowed_macros)] // for println!
fn main() {
lalrpop::process_root().unwrap();
let git_hash = Command::new("git2")
.args(["rev-parse", "--short", "HEAD"])
.output()
.map(|output| {
String::from_utf8(output.stdout)
.map(|s| "_".to_owned() + &s)
.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);
println!("cargo:rustc-env=FULL_VERSION={}", full_version);
}
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::io::{self, BufRead, BufReader};
use std::path::PathBuf;

#[derive(Debug, Parser)]
#[command(version = env!("FULL_VERSION"), about = env!("CARGO_PKG_DESCRIPTION"))]
struct Args {
#[clap(short = 'F', long)]
fact_directory: Option<PathBuf>,
Expand Down Expand Up @@ -126,7 +127,7 @@ fn main() {

if args.inputs.is_empty() {
let stdin = io::stdin();
log::info!("Welcome to Egglog!");
log::info!("Welcome to Egglog! (build: {})", env!("FULL_VERSION"));
let mut egraph = mk_egraph();

let mut cmd_buffer = String::new();
Expand Down

0 comments on commit c5fa39d

Please sign in to comment.