From cab64c57b0b0e7fa8140ed58c57043a56d16358b Mon Sep 17 00:00:00 2001 From: Yihong Zhang Date: Wed, 25 Sep 2024 15:01:15 -0700 Subject: [PATCH 1/5] add build info when running egglog --- Cargo.lock | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + build.rs | 11 +++++++ src/main.rs | 3 +- 4 files changed, 97 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index f61fc317..cc41b395 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,6 +40,21 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anstream" version = "0.6.13" @@ -160,6 +175,15 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "cc" +version = "1.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +dependencies = [ + "shlex", +] + [[package]] name = "cfg-if" version = "0.1.10" @@ -172,6 +196,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets 0.52.4", +] + [[package]] name = "clap" version = "4.5.4" @@ -228,6 +266,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "cpufeatures" version = "0.2.12" @@ -303,6 +347,7 @@ checksum = "675e35c02a51bb4d4618cb4885b3839ce6d1787c97b664474d9208d074742e20" name = "egglog" version = "0.2.0" dependencies = [ + "chrono", "clap", "egraph-serialize", "env_logger", @@ -487,6 +532,29 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "im-rc" version = "15.1.0" @@ -1059,6 +1127,12 @@ dependencies = [ "digest", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "siphasher" version = "0.3.11" @@ -1387,6 +1461,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.4", +] + [[package]] name = "windows-sys" version = "0.52.0" diff --git a/Cargo.toml b/Cargo.toml index 777b549d..375ebbe4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,6 +62,7 @@ im-rc = "15.1.0" [build-dependencies] lalrpop = "0.20" +chrono = "0.4" [dev-dependencies] glob = "0.3.1" diff --git a/build.rs b/build.rs index ca5c2836..ab7eb078 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,14 @@ +use std::{env, process::Command}; + fn main() { lalrpop::process_root().unwrap(); + let output = Command::new("git") + .args(&["rev-parse", "--short", "HEAD"]) + .output() + .unwrap(); + let git_hash = String::from_utf8(output.stdout).unwrap(); + let build_date = chrono::Local::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); } diff --git a/src/main.rs b/src/main.rs index dbd5e691..54d3d129 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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, @@ -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(); From 4b5769ef8d249063527e0ffcc7d1c5bb6dbeb389 Mon Sep 17 00:00:00 2001 From: Yihong Zhang Date: Wed, 25 Sep 2024 15:11:56 -0700 Subject: [PATCH 2/5] get rid of unwanted deps --- Cargo.lock | 73 ------------------------------------------------------ Cargo.toml | 2 +- build.rs | 2 +- 3 files changed, 2 insertions(+), 75 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc41b395..5c9225e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,21 +40,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "anstream" version = "0.6.13" @@ -175,15 +160,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" -[[package]] -name = "cc" -version = "1.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" -dependencies = [ - "shlex", -] - [[package]] name = "cfg-if" version = "0.1.10" @@ -202,12 +178,7 @@ version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ - "android-tzdata", - "iana-time-zone", - "js-sys", "num-traits", - "wasm-bindgen", - "windows-targets 0.52.4", ] [[package]] @@ -266,12 +237,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -532,29 +497,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "iana-time-zone" -version = "0.1.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - [[package]] name = "im-rc" version = "15.1.0" @@ -1127,12 +1069,6 @@ dependencies = [ "digest", ] -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - [[package]] name = "siphasher" version = "0.3.11" @@ -1461,15 +1397,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets 0.52.4", -] - [[package]] name = "windows-sys" version = "0.52.0" diff --git a/Cargo.toml b/Cargo.toml index 375ebbe4..694cf2d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,7 @@ im-rc = "15.1.0" [build-dependencies] lalrpop = "0.20" -chrono = "0.4" +chrono = { version = "0.4", default-features = false, features = ["now"] } [dev-dependencies] glob = "0.3.1" diff --git a/build.rs b/build.rs index ab7eb078..06999108 100644 --- a/build.rs +++ b/build.rs @@ -7,7 +7,7 @@ fn main() { .output() .unwrap(); let git_hash = String::from_utf8(output.stdout).unwrap(); - let build_date = chrono::Local::now().format("%Y-%m-%d"); + 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); From 5bf9deee3729e9a3a4640a158b85eaf13d6ae497 Mon Sep 17 00:00:00 2001 From: Yihong Zhang Date: Wed, 25 Sep 2024 15:13:53 -0700 Subject: [PATCH 3/5] nits --- build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 06999108..7e6f35e3 100644 --- a/build.rs +++ b/build.rs @@ -1,9 +1,10 @@ use std::{env, process::Command}; +#[allow(clippy::disallowed_macros)] // for println! fn main() { lalrpop::process_root().unwrap(); let output = Command::new("git") - .args(&["rev-parse", "--short", "HEAD"]) + .args(["rev-parse", "--short", "HEAD"]) .output() .unwrap(); let git_hash = String::from_utf8(output.stdout).unwrap(); From f86182e33818e1646b25f7649ec8c05aa0400266 Mon Sep 17 00:00:00 2001 From: Yihong Zhang Date: Thu, 26 Sep 2024 14:30:20 -0700 Subject: [PATCH 4/5] optional git --- build.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index 7e6f35e3..1bfb473c 100644 --- a/build.rs +++ b/build.rs @@ -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); } From 821cfb5b53f69d0a47e53cec9be04c96278f3c2f Mon Sep 17 00:00:00 2001 From: Yihong Zhang Date: Thu, 26 Sep 2024 14:34:29 -0700 Subject: [PATCH 5/5] oops --- build.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 1bfb473c..9de268e8 100644 --- a/build.rs +++ b/build.rs @@ -3,10 +3,14 @@ use std::{env, process::Command}; #[allow(clippy::disallowed_macros)] // for println! fn main() { lalrpop::process_root().unwrap(); - let git_hash = Command::new("git") + let git_hash = Command::new("git2") .args(["rev-parse", "--short", "HEAD"]) .output() - .map(|output| String::from_utf8(output.stdout).unwrap_or_default()) + .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();