diff --git a/Cargo.lock b/Cargo.lock index a4887a78..0c0d027c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -995,11 +995,13 @@ checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" [[package]] name = "cc" -version = "1.0.88" +version = "1.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" +checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" dependencies = [ + "jobserver", "libc", + "shlex", ] [[package]] @@ -1187,6 +1189,26 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "const_format" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -2718,6 +2740,12 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +[[package]] +name = "is_debug" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06d198e9919d9822d5f7083ba8530e04de87841eaf21ead9af8f2304efd57c89" + [[package]] name = "iter-read" version = "1.0.1" @@ -2779,6 +2807,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + [[package]] name = "jpeg-decoder" version = "0.3.1" @@ -3039,6 +3076,7 @@ dependencies = [ "parking_lot", "poll-promise", "rfd", + "shadow-rs", "steamworks", "strum", "tempfile", @@ -3829,6 +3867,15 @@ dependencies = [ "syn 2.0.51", ] +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + [[package]] name = "objc" version = "0.2.7" @@ -5144,6 +5191,17 @@ dependencies = [ "digest", ] +[[package]] +name = "shadow-rs" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d4535372eab969a98536e39dd272bca49fc338b09b25babea715968d15eeae" +dependencies = [ + "const_format", + "is_debug", + "time", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -5621,7 +5679,9 @@ checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "libc", "num-conv", + "num_threads", "powerfmt", "serde", "time-core", diff --git a/Cargo.toml b/Cargo.toml index 2b4cf668..e74c026b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -208,6 +208,7 @@ async-std.workspace = true futures-lite.workspace = true git-version = "0.3.9" +shadow-rs = { version = "0.32.0", default-features = false } # Native [target.'cfg(not(target_arch = "wasm32"))'.dependencies] @@ -264,6 +265,9 @@ features = ["webgpu", "webgl"] [features] steamworks = ["dep:steamworks"] +[build-dependencies] +shadow-rs = { version = "0.32.0", default-features = false } + [target.'cfg(windows)'.build-dependencies] winres = "0.1" diff --git a/build.rs b/build.rs index ebc15590..9830619b 100644 --- a/build.rs +++ b/build.rs @@ -35,4 +35,6 @@ fn main() { let _ = res.compile(); } + + shadow_rs::new().unwrap(); } diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 44292ccc..b6b61db2 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -88,7 +88,16 @@ pub struct UpdateState<'res> { pub modified_during_prev_frame: &'res mut bool, pub project_manager: &'res mut ProjectManager, + pub build_diagnostics: &'static BuildDiagnostics, +} + +pub struct BuildDiagnostics { + pub build_time: &'static str, pub git_revision: &'static str, + pub rustc_version: &'static str, + pub cargo_version: &'static str, + pub build_os: &'static str, + pub is_debug: bool, } /// This stores whether or not there are unsaved changes in any file in the current project and is @@ -206,7 +215,7 @@ impl<'res> UpdateState<'res> { modified: self.modified.clone(), modified_during_prev_frame: self.modified_during_prev_frame, project_manager: self.project_manager, - git_revision: self.git_revision, + build_diagnostics: self.build_diagnostics, } } @@ -230,7 +239,7 @@ impl<'res> UpdateState<'res> { modified: self.modified.clone(), modified_during_prev_frame: self.modified_during_prev_frame, project_manager: self.project_manager, - git_revision: self.git_revision, + build_diagnostics: self.build_diagnostics, } } diff --git a/crates/ui/src/windows/about.rs b/crates/ui/src/windows/about.rs index 27812631..4aa7dcc7 100644 --- a/crates/ui/src/windows/about.rs +++ b/crates/ui/src/windows/about.rs @@ -63,9 +63,6 @@ impl luminol_core::Window for Window { ui.add(self.icon.clone()); ui.heading("Luminol"); - ui.separator(); - ui.label(format!("Luminol version {}", env!("CARGO_PKG_VERSION"))); - ui.label(format!("git-rev {}", update_state.git_revision)); ui.separator(); ui.label("Luminol is a FOSS version of the RPG Maker XP editor."); @@ -74,7 +71,31 @@ impl luminol_core::Window for Window { ui.label(format!( "Authors: \n{}", env!("CARGO_PKG_AUTHORS").replace(':', "\n") - )) + )); + ui.separator(); + + ui.label(format!("Luminol version {}", env!("CARGO_PKG_VERSION"))); + ui.label("--- Build time info ---"); + ui.label(format!( + "git-rev {}", + update_state.build_diagnostics.git_revision + )); + ui.label(format!( + "built on {}", + update_state.build_diagnostics.build_time + )); + ui.label(format!( + "build OS: {}", + update_state.build_diagnostics.build_os + )); + ui.label("--- Build info ---"); + ui.label(update_state.build_diagnostics.rustc_version); + ui.label(update_state.build_diagnostics.cargo_version); + if update_state.build_diagnostics.is_debug { + ui.label("Debug build"); + } else { + ui.label("Release build"); + } }) }); } diff --git a/src/app/mod.rs b/src/app/mod.rs index 5f1047b8..adf354b0 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -24,9 +24,9 @@ use std::sync::Arc; -use crate::lumi::Lumi; #[cfg(feature = "steamworks")] use crate::steam::Steamworks; +use crate::{lumi::Lumi, BUILD_DIAGNOSTIC}; #[cfg(not(target_arch = "wasm32"))] mod log_window; @@ -344,7 +344,7 @@ impl luminol_eframe::App for App { modified: self.modified.clone(), modified_during_prev_frame: &mut self.modified_during_prev_frame, project_manager: &mut self.project_manager, - git_revision: crate::git_revision(), + build_diagnostics: &BUILD_DIAGNOSTIC, }; // If a file/folder picker is open, prevent the user from interacting with the application diff --git a/src/main.rs b/src/main.rs index d5d4dfc2..ff68eca4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,7 +14,6 @@ // // You should have received a copy of the GNU General Public License // along with Luminol. If not, see . -//cargo r // Additional permission under GNU GPL version 3 section 7 // // If you modify this Program, or any covered work, by linking or combining @@ -25,6 +24,8 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(target_arch = "wasm32", no_main)] // there is no main function in web builds +shadow_rs::shadow!(build); + #[cfg(not(target_arch = "wasm32"))] use std::io::{Read, Write}; @@ -49,15 +50,28 @@ compile_error!("Steamworks is not supported on webassembly"); #[cfg(feature = "steamworks")] mod steam; -pub fn git_revision() -> &'static str { +const fn git_revision() -> &'static str { #[cfg(not(target_arch = "wasm32"))] { git_version::git_version!() } + // I would reach for unwrap_or but it's not const fn yet #[cfg(target_arch = "wasm32")] - option_env!("LUMINOL_VERSION").unwrap_or(git_version::git_version!()) + match option_env!("LUMINOL_VERSION") { + Some(v) => v, + None => git_version::git_version!(), + } } +pub const BUILD_DIAGNOSTIC: luminol_core::BuildDiagnostics = luminol_core::BuildDiagnostics { + build_time: build::BUILD_TIME, + rustc_version: build::RUST_VERSION, + cargo_version: build::CARGO_VERSION, + build_os: build::BUILD_OS, + git_revision: git_revision(), + is_debug: cfg!(debug_assertions), +}; + #[cfg(not(target_arch = "wasm32"))] fn main() { // Load the panic report from the previous run if it exists