diff --git a/.gitignore b/.gitignore index af864be..51d78b1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ result # Web output dist/* + +# Generated VERSION file for builds +VERSION diff --git a/Cargo.lock b/Cargo.lock index c0b2b52..6516517 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,6 +160,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_log-sys" version = "0.3.2" @@ -1586,6 +1592,20 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + [[package]] name = "clang-sys" version = "1.8.1" @@ -2205,6 +2225,7 @@ version = "0.1.0" dependencies = [ "bevy", "bevy_rapier3d", + "chrono", "serde", "thiserror 2.0.12", ] @@ -2502,6 +2523,30 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core 0.61.2", +] + +[[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 = "image" version = "0.25.6" diff --git a/Cargo.toml b/Cargo.toml index 00b7a32..9bcf9db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,3 +16,6 @@ version = "0.30.0" [dependencies.bevy] version = "0.16.1" features = ["wayland", "dynamic_linking"] + +[build-dependencies] +chrono = "*" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..828dc6d --- /dev/null +++ b/build.rs @@ -0,0 +1,38 @@ +fn main() { + { + use std::process::Command; + use chrono::prelude::*; + use std::fs::File; + use std::io::Write; + + // Date of build + let now = Utc::now().format("%Y%m%d%H%M%S"); + + // Latest commit ID + let git_sha = String::from_utf8( + Command::new("git") + .arg("rev-parse") + .arg("--short") + .arg("HEAD") + .output() + .expect("Failed to get git sha") + .stdout + ).expect("Read stdout from git sha command"); + + // If the workspace is dirty or clean + let clean = Command::new("git") + .arg("diff") + .arg("--quiet") + .status() + .expect("Failed to run git diff") + .success(); + + let mut file = File::create("VERSION").expect("Create VERSION file"); + + if clean { + write!(file, "0.0.0-{now}+{}", git_sha.trim()).expect("Write version to VERSION file"); + } else { + write!(file, "0.0.0-{now}+{}-dirty", git_sha.trim()).expect("Write version to VERSION file"); + } + } +} diff --git a/src/bin/trees/main.rs b/src/bin/trees/main.rs index 415dc52..33ff2f2 100644 --- a/src/bin/trees/main.rs +++ b/src/bin/trees/main.rs @@ -182,7 +182,6 @@ fn init_debug_ui(mut commands: Commands) { height: Val::Percent(90.0), align_self: AlignSelf::Center, justify_self: JustifySelf::Start, - width: Val::Percent(60.0), ..default() }, MonologuesContainer, diff --git a/src/debug.rs b/src/debug.rs index 5211a50..012cfdd 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -1,5 +1,5 @@ use bevy::{ - color::palettes::css::MAGENTA, + color::palettes::css::{GREY, MAGENTA}, pbr::wireframe::{WireframeConfig, WireframePlugin}, platform::collections::HashMap, }; @@ -61,8 +61,10 @@ pub enum DebuggingState { /// Create the Debugging UI fn init_debug_ui(mut commands: Commands) { + // "Debugging On" Indicator commands.spawn(( DebuggingState::On, + Name::new("Debug Indicator"), Text(" Debug: ON ".into()), TextColor(WHITE.into()), BackgroundColor(RED.into()), @@ -74,6 +76,22 @@ fn init_debug_ui(mut commands: Commands) { }, )); + // Version string for troubleshooting + commands.spawn(( + DebuggingState::On, + Name::new("Version #"), + Text::new(VERSION), + TextColor(WHITE.into()), + BackgroundColor(BLACK.into()), + Node { + width: Val::Auto, + align_self: AlignSelf::End, + justify_self: JustifySelf::End, + ..default() + } + )); + + // Tooltip commands.spawn(( DebuggingState::On, Text("Tooltip Placeholder".into()), diff --git a/src/lib.rs b/src/lib.rs index bf1b60c..251414c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,7 @@ mod debug; mod loading; mod scheduling; mod ui; +mod version; pub use std::fmt::Display; @@ -28,3 +29,4 @@ pub use debug::*; pub use loading::*; pub use scheduling::*; pub use ui::*; +pub use version::*; diff --git a/src/version.rs b/src/version.rs new file mode 100644 index 0000000..86efe47 --- /dev/null +++ b/src/version.rs @@ -0,0 +1,2 @@ +/// Include the version of this build from an auto-generated version file +pub const VERSION: &str = include_str!("../VERSION");