diff --git a/Cargo.lock b/Cargo.lock index 616a1ac..2a9c2ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4574,7 +4574,7 @@ dependencies = [ [[package]] name = "wlx-overlay-s" -version = "0.4.3" +version = "0.4.4" dependencies = [ "anyhow", "ash", diff --git a/Cargo.toml b/Cargo.toml index 1c0cdfb..eba41c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ debug = true [package] name = "wlx-overlay-s" -version = "0.4.3" +version = "0.4.4" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -70,6 +70,9 @@ image_dds = { version = "0.6.0", default-features = false, features = [ ] } mint = "0.5.9" +[build-dependencies] +regex = { version = "*" } + [features] default = ["openvr", "openxr", "osc", "x11", "wayland"] openvr = ["dep:ovr_overlay", "dep:json"] diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..49ae80d --- /dev/null +++ b/build.rs @@ -0,0 +1,23 @@ +use regex::Regex; +use std::process::Command; + +fn main() { + let mut wlx_build = get_version().unwrap_or(format!("{} (Cargo)", env!("CARGO_PKG_VERSION"))); + + if std::env::var("GITHUB_ACTIONS").is_ok() { + wlx_build = format!("{} (AppImage)", &wlx_build) + } + + println!("cargo:rustc-env=WLX_BUILD={}", &wlx_build); +} + +fn get_version() -> Result> { + let re = Regex::new(r"v([0-9.]+)-([0-9]+)-g([a-f0-9]+)").unwrap(); // safe + let output = Command::new("git") + .args(["describe", "--tags", "--abbrev=7"]) + .output()?; + + let output_str = String::from_utf8(output.stdout)?; + + Ok(re.replace_all(&output_str, "${1}.r${2}.${3}").into_owned()) +} diff --git a/src/main.rs b/src/main.rs index 416a8e8..8ca26f2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,7 +79,7 @@ fn main() -> Result<(), Box> { log::info!( "Welcome to {} version {}!", env!("CARGO_PKG_NAME"), - env!("CARGO_PKG_VERSION") + env!("WLX_BUILD"), ); log::info!("It is {}.", chrono::Local::now().format("%c"));