mirror of
https://github.com/SpaceManiac/SpacemanDMM.git
synced 2025-12-23 05:36:47 +00:00
Add version info to editor help menu
This commit is contained in:
parent
bd9a5fce3b
commit
9fc0112f8c
3 changed files with 38 additions and 5 deletions
|
|
@ -31,3 +31,7 @@ slice-of-array = "0.2.0"
|
|||
[dependencies.nfd]
|
||||
git = "https://github.com/SpaceManiac/nfd-rs"
|
||||
branch = "zenity"
|
||||
|
||||
[build-dependencies]
|
||||
chrono = "0.4.0"
|
||||
git2 = { version = "0.10", default-features = false }
|
||||
|
|
|
|||
|
|
@ -1,8 +1,23 @@
|
|||
use std::process::Command;
|
||||
extern crate chrono;
|
||||
extern crate git2;
|
||||
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::process::Command;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
fn main() {
|
||||
// build info
|
||||
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
let mut f = File::create(&out_dir.join("build-info.txt")).unwrap();
|
||||
|
||||
if let Ok(commit) = read_commit() {
|
||||
writeln!(f, "commit: {}", commit).unwrap();
|
||||
}
|
||||
writeln!(f, "build date: {}", chrono::Utc::today()).unwrap();
|
||||
|
||||
// windres icon
|
||||
if cfg!(windows) {
|
||||
let out_dir = env::var("OUT_DIR").ok().expect("can't find out_dir");
|
||||
|
||||
|
|
@ -37,3 +52,9 @@ fn main() {
|
|||
println!("cargo:rustc-link-lib=static=editor_rc");
|
||||
}
|
||||
}
|
||||
|
||||
fn read_commit() -> Result<String, git2::Error> {
|
||||
let repo = git2::Repository::discover(".")?;
|
||||
let hash = repo.head()?.peel_to_commit()?.id().to_string();
|
||||
Ok(hash)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -570,9 +570,17 @@ impl EditorScene {
|
|||
});
|
||||
}
|
||||
ui.menu(im_str!("Help"), true, || {
|
||||
MenuItem::new(im_str!("About SpacemanDMM"))
|
||||
.enabled(false)
|
||||
.build(ui);
|
||||
ui.menu(im_str!("About SpacemanDMM"), true, || {
|
||||
ui.bullet_text(&im_str!(
|
||||
"{} {} Copyright (C) 2017-2019 Tad Hardesty",
|
||||
env!("CARGO_PKG_NAME"),
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
));
|
||||
ui.bullet_text(&im_str!("{}", include_str!(concat!(env!("OUT_DIR"), "/build-info.txt"))));
|
||||
ui.bullet_text(im_str!("This program comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
|
||||
and you are welcome to redistribute it under the conditions of the GNU\n\
|
||||
General Public License version 3."));
|
||||
});
|
||||
MenuItem::new(im_str!("Open-source licenses"))
|
||||
.enabled(false)
|
||||
.build(ui);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue