diff --git a/gui/assets/main.scss b/gui/assets/main.scss index 6682bb7..0b4cc09 100644 --- a/gui/assets/main.scss +++ b/gui/assets/main.scss @@ -279,6 +279,11 @@ a:visited { color: #b3c6b4; } + &_version { + color: var(--txt-color); + font-weight: normal; + } + &_bttn { font-weight: bold; font-size: large; diff --git a/gui/build.rs b/gui/build.rs index ab4c843..8af6acb 100644 --- a/gui/build.rs +++ b/gui/build.rs @@ -1,7 +1,39 @@ +use std::env; use std::path::Path; use std::process::Command; -fn main() { +fn version_env() -> Option<()> { + if env::var("MUMBLE_WEB2_VERSION").is_ok() { + return Some(()); + } + + let output = Command::new("git") + .args(["rev-parse", "--short", "HEAD"]) + .output() + .ok()?; + + let git_hash = String::from_utf8(output.stdout).ok()?; + let git_hash = git_hash.trim(); // drop trailing newline + + let status = Command::new("git") + .args(["status", "--porcelain"]) + .output() + .ok()?; + let dirty = match status.stdout.is_empty() { + true => "", + false => "-dirty", + }; + + // Expose it as a compile-time env var + println!("cargo::rustc-env=MUMBLE_WEB2_VERSION=git-{git_hash}{dirty}"); + + // Optional: rebuild when HEAD changes + println!("cargo::rerun-if-changed=.git/HEAD"); + + Some(()) +} + +fn download_deepfilternet() { // Define the target directory and file let assets_dir = "assets"; let target_file = format!("{}/DeepFilterNet3_ll_onnx.tar.gz", assets_dir); @@ -9,30 +41,46 @@ fn main() { // Check if the file already exists if target_path.exists() { - println!("cargo:warning=DeepFilterNet model already exists at {}", target_file); + println!( + "cargo::warning=DeepFilterNet model already exists at {}", + target_file + ); return; } - println!("cargo:warning=Downloading DeepFilterNet model to {}...", target_file); + println!( + "cargo::warning=Downloading DeepFilterNet model to {}...", + target_file + ); // Download the file using curl let url = "https://github.com/Rikorose/DeepFilterNet/raw/refs/heads/main/models/DeepFilterNet3_ll_onnx.tar.gz"; let status = Command::new("curl") .args([ - "-L", // Follow redirects - "-o", &target_file, // Output file + "-L", // Follow redirects + "-o", + &target_file, // Output file url, ]) .status() .expect("Failed to execute curl command. Make sure curl is installed."); if !status.success() { - panic!("Failed to download DeepFilterNet model from {}", url); + println!("cargo::error=Failed to download DeepFilterNet model from {url}"); + return; } - println!("cargo:warning=Successfully downloaded DeepFilterNet model to {}", target_file); + println!( + "cargo::warning=Successfully downloaded DeepFilterNet model to {}", + target_file + ); // Rerun this build script if the target file is deleted - println!("cargo:rerun-if-changed={}", target_file); + println!("cargo::rerun-if-changed={}", target_file); +} + +fn main() { + version_env(); + download_deepfilternet(); } diff --git a/gui/src/app.rs b/gui/src/app.rs index c6f6c78..efe2ff8 100644 --- a/gui/src/app.rs +++ b/gui/src/app.rs @@ -612,11 +612,16 @@ pub fn LoginView(config: Resource) -> Element { ), Connected => unreachable!(), }; + let version = option_env!("MUMBLE_WEB2_VERSION"); rsx!( div { class: "login", h1 { "Mumble Web" + match version { + Some(v) => rsx!(" " span { class: "login_version", "({v})" }), + None => rsx!(), + } } if config.read().as_ref().is_some_and(|cfg| cfg.any_server) { div {