aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG1
-rw-r--r--mumctl/build.rs19
-rw-r--r--mumctl/src/main.rs1
-rw-r--r--mumd/build.rs19
-rw-r--r--mumd/src/main.rs5
5 files changed, 45 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 060890f..7ae6e9d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -20,6 +20,7 @@ Added
* Added a noise gate
* Added tunneling audio through TCP if UDP connection goes down
+* --version now includes the current commit hash.
// Changed
// ~~~~~~~
diff --git a/mumctl/build.rs b/mumctl/build.rs
new file mode 100644
index 0000000..0a4f506
--- /dev/null
+++ b/mumctl/build.rs
@@ -0,0 +1,19 @@
+use std::process::Command;
+
+fn main() {
+ let version = match commit_hash().as_deref() {
+ None | Some("") => format!("v{}", env!("CARGO_PKG_VERSION")),
+ Some(version) => version.to_string(),
+ };
+
+ println!("cargo:rustc-env=VERSION={}", version);
+}
+
+fn commit_hash() -> Option<String> {
+ let output = Command::new("git")
+ .arg("describe")
+ .arg("--tags")
+ .current_dir(env!("CARGO_MANIFEST_DIR"))
+ .output();
+ output.ok().map(|o| String::from_utf8_lossy(&o.stdout).to_string())
+}
diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs
index d43ff4f..d07a482 100644
--- a/mumctl/src/main.rs
+++ b/mumctl/src/main.rs
@@ -53,6 +53,7 @@ fn main() {
let mut app = App::new("mumctl")
.setting(AppSettings::ArgRequiredElseHelp)
+ .version(env!("VERSION"))
.subcommand(
SubCommand::with_name("connect")
.about("Connect to a server")
diff --git a/mumd/build.rs b/mumd/build.rs
new file mode 100644
index 0000000..0a4f506
--- /dev/null
+++ b/mumd/build.rs
@@ -0,0 +1,19 @@
+use std::process::Command;
+
+fn main() {
+ let version = match commit_hash().as_deref() {
+ None | Some("") => format!("v{}", env!("CARGO_PKG_VERSION")),
+ Some(version) => version.to_string(),
+ };
+
+ println!("cargo:rustc-env=VERSION={}", version);
+}
+
+fn commit_hash() -> Option<String> {
+ let output = Command::new("git")
+ .arg("describe")
+ .arg("--tags")
+ .current_dir(env!("CARGO_MANIFEST_DIR"))
+ .output();
+ output.ok().map(|o| String::from_utf8_lossy(&o.stdout).to_string())
+}
diff --git a/mumd/src/main.rs b/mumd/src/main.rs
index 0526930..7c3745c 100644
--- a/mumd/src/main.rs
+++ b/mumd/src/main.rs
@@ -15,6 +15,11 @@ use tokio::task::spawn_blocking;
#[tokio::main]
async fn main() {
+ if std::env::args().find(|s| s.as_str() == "--version").is_some() {
+ println!("mumd {}", env!("VERSION"));
+ return;
+ }
+
setup_logger(std::io::stderr(), true);
notify::init();