From 16d721be8c1b9050086e7137d11a2bfa940c4b3f Mon Sep 17 00:00:00 2001 From: alloncm Date: Fri, 13 Dec 2024 20:46:03 +0200 Subject: [PATCH] Add the short git commit hash to the version --- common/build.rs | 8 ++++++++ common/src/lib.rs | 2 +- libretro/Cargo.toml | 5 ++++- libretro/build.rs | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 common/build.rs diff --git a/common/build.rs b/common/build.rs new file mode 100644 index 00000000..37336f5f --- /dev/null +++ b/common/build.rs @@ -0,0 +1,8 @@ +use std::process::Command; + +fn main() { + let output = Command::new("git").args(&["rev-parse", "--short", "HEAD"]).output().unwrap(); + let git_hash = String::from_utf8(output.stdout).unwrap(); + let version = env!("CARGO_PKG_VERSION"); + println!("cargo:rustc-env=MAGENBOY_VERSION={}", std::format!("{}-{}", version, git_hash)); +} \ No newline at end of file diff --git a/common/src/lib.rs b/common/src/lib.rs index 4cdd67f4..0090a992 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -18,4 +18,4 @@ pub mod menu; pub mod joypad_menu; pub mod interpolation; -pub const VERSION:&str = env!("CARGO_PKG_VERSION"); \ No newline at end of file +pub const VERSION:&str = env!("MAGENBOY_VERSION"); \ No newline at end of file diff --git a/libretro/Cargo.toml b/libretro/Cargo.toml index 7a38ef47..c1736eb1 100644 --- a/libretro/Cargo.toml +++ b/libretro/Cargo.toml @@ -14,4 +14,7 @@ crate-type = ["cdylib"] magenboy_core = {path = "../core", features = ["apu"]} magenboy_common = {path = "../common/", features = ["std"]} libretro-sys = "0.1.1" -log = "0.4" \ No newline at end of file +log = "0.4" + +[build-dependencies] +magenboy_common = {path = "../common"} \ No newline at end of file diff --git a/libretro/build.rs b/libretro/build.rs index 3d20705e..5cf98037 100644 --- a/libretro/build.rs +++ b/libretro/build.rs @@ -17,7 +17,7 @@ fn main() { info_filename.pop(); info_filename = info_filename.join(executable_filename); info_filename.set_extension("info"); - let version = var("CARGO_PKG_VERSION").unwrap(); + let version = magenboy_common::VERSION; let authors = var("CARGO_PKG_AUTHORS").unwrap(); let content = std::format!( r##"display_name = "MagenBoy - GameBoy & GameBoy Color"