From ae9b50cad90dd61484e498ea092e9dd947168fdd Mon Sep 17 00:00:00 2001 From: J Pratt Date: Thu, 10 Mar 2022 15:01:49 +1100 Subject: [PATCH] Add version information to output for debugging Change-Id: I394069317390d22ee92523cada842b00487c7c9e --- ibis/Cargo.lock | 200 +++++++++++++++++++++++++++++++++++++++++++ ibis/Cargo.toml | 5 ++ ibis/build.rs | 3 + ibis/src/bin/main.rs | 1 + ibis/src/lib.rs | 20 ++++- 5 files changed, 225 insertions(+), 4 deletions(-) create mode 100644 ibis/build.rs diff --git a/ibis/Cargo.lock b/ibis/Cargo.lock index fddc377a1..b5b26aa5d 100644 --- a/ibis/Cargo.lock +++ b/ibis/Cargo.lock @@ -25,6 +25,7 @@ dependencies = [ "pretty_assertions", "serde", "serde_json", + "shadow-rs", "wasm-bindgen", ] @@ -82,12 +83,34 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +dependencies = [ + "jobserver", +] + [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "time", + "winapi", +] + [[package]] name = "clap" version = "2.34.0" @@ -252,6 +275,29 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "git2" +version = "0.13.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29229cc1b24c0e6062f6e742aa3e256492a5323365e5ed3413599f8a5eff7d6" +dependencies = [ + "bitflags", + "libc", + "libgit2-sys", + "log", + "url", +] + [[package]] name = "half" version = "1.8.2" @@ -273,6 +319,17 @@ dependencies = [ "libc", ] +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indexmap" version = "1.7.0" @@ -283,6 +340,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "is_debug" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06d198e9919d9822d5f7083ba8530e04de87841eaf21ead9af8f2304efd57c89" + [[package]] name = "itertools" version = "0.10.3" @@ -304,6 +367,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +[[package]] +name = "jobserver" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.56" @@ -325,6 +397,30 @@ version = "0.2.119" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" +[[package]] +name = "libgit2-sys" +version = "0.12.26+1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e1c899248e606fbfe68dcb31d8b0176ebab833b103824af31bddf4b7457494" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + +[[package]] +name = "libz-sys" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f35facd4a5673cb5a48822be2be1d4236c1c99cb4113cab7061ac720d5bf859" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "log" version = "0.4.14" @@ -334,6 +430,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "matches" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" + [[package]] name = "memchr" version = "2.4.1" @@ -366,6 +468,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.14" @@ -406,6 +518,12 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5" +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + [[package]] name = "petgraph" version = "0.5.1" @@ -416,6 +534,12 @@ dependencies = [ "indexmap", ] +[[package]] +name = "pkg-config" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" + [[package]] name = "plotters" version = "0.3.1" @@ -621,6 +745,17 @@ dependencies = [ "serde", ] +[[package]] +name = "shadow-rs" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38aacac9d96bfdac3f00d2149fc2235f99b839f54f0bb18bea39c7749c97f709" +dependencies = [ + "chrono", + "git2", + "is_debug", +] + [[package]] name = "syn" version = "1.0.85" @@ -641,6 +776,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "time" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +dependencies = [ + "libc", + "wasi", + "winapi", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -651,6 +797,36 @@ dependencies = [ "serde_json", ] +[[package]] +name = "tinyvec" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "unicode-bidi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" + +[[package]] +name = "unicode-normalization" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-width" version = "0.1.9" @@ -663,6 +839,24 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +[[package]] +name = "url" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" @@ -680,6 +874,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + [[package]] name = "wasm-bindgen" version = "0.2.79" diff --git a/ibis/Cargo.toml b/ibis/Cargo.toml index 941f4806b..be0fbb205 100644 --- a/ibis/Cargo.toml +++ b/ibis/Cargo.toml @@ -5,6 +5,7 @@ edition = "2021" description = "Ibis - a knowledge engine for type checking asynchronously communicating modules" repository = "https://github.com/project-oak/arcsjs-provable" license = "See LICENSE" +build = "build.rs" [lib] name = "ibis" @@ -20,6 +21,7 @@ dot = [] # Support the generation of dot graphs (for debugging) wasm = [ "wasm-bindgen", "console_error_panic_hook" ] # Support wasm-bindgen API [dependencies] +shadow-rs = { version = "0.9", default-features = false } nom = "7.1.0" paste = "1.0.6" crepe = "0.1.6" @@ -34,6 +36,9 @@ console_error_panic_hook = { version = "0.1.7", optional = true } pretty_assertions = "1.0.0" criterion = { version = "0.3", features = ["html_reports"] } +[build-dependencies] +shadow-rs = "0.9" + [profile.release] opt-level = "z" lto = "fat" diff --git a/ibis/build.rs b/ibis/build.rs new file mode 100644 index 000000000..4a0dfc459 --- /dev/null +++ b/ibis/build.rs @@ -0,0 +1,3 @@ +fn main() -> shadow_rs::SdResult<()> { + shadow_rs::new() +} diff --git a/ibis/src/bin/main.rs b/ibis/src/bin/main.rs index 5c611c005..69f359682 100644 --- a/ibis/src/bin/main.rs +++ b/ibis/src/bin/main.rs @@ -10,6 +10,7 @@ use ibis::IbisError; use std::io::Read; fn main() -> Result<(), IbisError> { + ibis::print_info(); let mut data = String::new(); std::io::stdin() .read_to_string(&mut data) diff --git a/ibis/src/lib.rs b/ibis/src/lib.rs index f961fa5f1..fca7e5505 100644 --- a/ibis/src/lib.rs +++ b/ibis/src/lib.rs @@ -29,6 +29,9 @@ pub use solution_data::SolutionData; pub use solution_id::Sol; pub use util::*; +use shadow_rs::shadow; +shadow!(build); + #[macro_export] macro_rules! ent { ($fmt: expr) => { @@ -96,6 +99,10 @@ pub fn get_solutions(data: &str, loss: Option) -> Ibis { runtime.extract_solutions_with_loss(loss) } +pub fn print_info() { + eprintln!("{}", build::version()); +} + #[cfg(feature = "wasm")] pub mod wasm { use wasm_bindgen::prelude::*; @@ -104,29 +111,34 @@ pub mod wasm { console_error_panic_hook::set_once(); } + fn setup() { + set_panic_hook(); + super::print_info(); + } + #[wasm_bindgen] pub fn best_solutions_to_json(data: &str) -> String { - set_panic_hook(); + setup(); super::best_solutions_to_json(data) } #[wasm_bindgen] pub fn all_solutions_to_json(data: &str) -> String { - set_panic_hook(); + setup(); super::all_solutions_to_json(data) } #[cfg(feature = "dot")] #[wasm_bindgen] pub fn best_solutions_to_dot(data: &str) -> String { - set_panic_hook(); + setup(); super::best_solutions_to_dot(data) } #[cfg(feature = "dot")] #[wasm_bindgen] pub fn all_solutions_to_dot(data: &str) -> String { - set_panic_hook(); + setup(); super::all_solutions_to_dot(data) } }