Skip to content

Commit

Permalink
More build diagnostics (#152)
Browse files Browse the repository at this point in the history
* Add some more build-time diagnostics to the about window

* Re-organize ui

* Disable git2 feature of shadow_rs

* use match instead of unwrap_or
  • Loading branch information
melody-rs authored Aug 16, 2024
1 parent 0cb37c6 commit 2bce7d8
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 13 deletions.
64 changes: 62 additions & 2 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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"

Expand Down
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ fn main() {

let _ = res.compile();
}

shadow_rs::new().unwrap();
}
13 changes: 11 additions & 2 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
}

Expand All @@ -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,
}
}

Expand Down
29 changes: 25 additions & 4 deletions crates/ui/src/windows/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -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");
}
})
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
//
// You should have received a copy of the GNU General Public License
// along with Luminol. If not, see <http://www.gnu.org/licenses/>.
//cargo r
// Additional permission under GNU GPL version 3 section 7
//
// If you modify this Program, or any covered work, by linking or combining
Expand All @@ -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};

Expand All @@ -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
Expand Down

0 comments on commit 2bce7d8

Please sign in to comment.