Detailed version string. (closes #62)

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-06-12 23:01:15 +00:00
parent b0b441d534
commit f1f31eff17
5 changed files with 55 additions and 20 deletions

22
Cargo.lock generated
View File

@@ -3384,7 +3384,7 @@ dependencies = [
[[package]]
name = "ruma"
version = "0.10.1"
source = "git+https://github.com/matrix-construct/ruma?rev=a91c1b70fa3cc57fc87a6ce92d2c42a19124a666#a91c1b70fa3cc57fc87a6ce92d2c42a19124a666"
source = "git+https://github.com/matrix-construct/ruma?rev=3d082885f6532cc84ba65ebd2c3ff31b25a7022d#3d082885f6532cc84ba65ebd2c3ff31b25a7022d"
dependencies = [
"assign",
"js_int",
@@ -3404,7 +3404,7 @@ dependencies = [
[[package]]
name = "ruma-appservice-api"
version = "0.10.0"
source = "git+https://github.com/matrix-construct/ruma?rev=a91c1b70fa3cc57fc87a6ce92d2c42a19124a666#a91c1b70fa3cc57fc87a6ce92d2c42a19124a666"
source = "git+https://github.com/matrix-construct/ruma?rev=3d082885f6532cc84ba65ebd2c3ff31b25a7022d#3d082885f6532cc84ba65ebd2c3ff31b25a7022d"
dependencies = [
"js_int",
"ruma-common",
@@ -3416,7 +3416,7 @@ dependencies = [
[[package]]
name = "ruma-client-api"
version = "0.18.0"
source = "git+https://github.com/matrix-construct/ruma?rev=a91c1b70fa3cc57fc87a6ce92d2c42a19124a666#a91c1b70fa3cc57fc87a6ce92d2c42a19124a666"
source = "git+https://github.com/matrix-construct/ruma?rev=3d082885f6532cc84ba65ebd2c3ff31b25a7022d#3d082885f6532cc84ba65ebd2c3ff31b25a7022d"
dependencies = [
"as_variant",
"assign",
@@ -3439,7 +3439,7 @@ dependencies = [
[[package]]
name = "ruma-common"
version = "0.13.0"
source = "git+https://github.com/matrix-construct/ruma?rev=a91c1b70fa3cc57fc87a6ce92d2c42a19124a666#a91c1b70fa3cc57fc87a6ce92d2c42a19124a666"
source = "git+https://github.com/matrix-construct/ruma?rev=3d082885f6532cc84ba65ebd2c3ff31b25a7022d#3d082885f6532cc84ba65ebd2c3ff31b25a7022d"
dependencies = [
"as_variant",
"base64",
@@ -3471,7 +3471,7 @@ dependencies = [
[[package]]
name = "ruma-events"
version = "0.28.1"
source = "git+https://github.com/matrix-construct/ruma?rev=a91c1b70fa3cc57fc87a6ce92d2c42a19124a666#a91c1b70fa3cc57fc87a6ce92d2c42a19124a666"
source = "git+https://github.com/matrix-construct/ruma?rev=3d082885f6532cc84ba65ebd2c3ff31b25a7022d#3d082885f6532cc84ba65ebd2c3ff31b25a7022d"
dependencies = [
"as_variant",
"indexmap",
@@ -3496,7 +3496,7 @@ dependencies = [
[[package]]
name = "ruma-federation-api"
version = "0.9.0"
source = "git+https://github.com/matrix-construct/ruma?rev=a91c1b70fa3cc57fc87a6ce92d2c42a19124a666#a91c1b70fa3cc57fc87a6ce92d2c42a19124a666"
source = "git+https://github.com/matrix-construct/ruma?rev=3d082885f6532cc84ba65ebd2c3ff31b25a7022d#3d082885f6532cc84ba65ebd2c3ff31b25a7022d"
dependencies = [
"bytes",
"headers",
@@ -3518,7 +3518,7 @@ dependencies = [
[[package]]
name = "ruma-identifiers-validation"
version = "0.9.5"
source = "git+https://github.com/matrix-construct/ruma?rev=a91c1b70fa3cc57fc87a6ce92d2c42a19124a666#a91c1b70fa3cc57fc87a6ce92d2c42a19124a666"
source = "git+https://github.com/matrix-construct/ruma?rev=3d082885f6532cc84ba65ebd2c3ff31b25a7022d#3d082885f6532cc84ba65ebd2c3ff31b25a7022d"
dependencies = [
"js_int",
"thiserror 2.0.12",
@@ -3527,7 +3527,7 @@ dependencies = [
[[package]]
name = "ruma-identity-service-api"
version = "0.9.0"
source = "git+https://github.com/matrix-construct/ruma?rev=a91c1b70fa3cc57fc87a6ce92d2c42a19124a666#a91c1b70fa3cc57fc87a6ce92d2c42a19124a666"
source = "git+https://github.com/matrix-construct/ruma?rev=3d082885f6532cc84ba65ebd2c3ff31b25a7022d#3d082885f6532cc84ba65ebd2c3ff31b25a7022d"
dependencies = [
"js_int",
"ruma-common",
@@ -3537,7 +3537,7 @@ dependencies = [
[[package]]
name = "ruma-macros"
version = "0.13.0"
source = "git+https://github.com/matrix-construct/ruma?rev=a91c1b70fa3cc57fc87a6ce92d2c42a19124a666#a91c1b70fa3cc57fc87a6ce92d2c42a19124a666"
source = "git+https://github.com/matrix-construct/ruma?rev=3d082885f6532cc84ba65ebd2c3ff31b25a7022d#3d082885f6532cc84ba65ebd2c3ff31b25a7022d"
dependencies = [
"cfg-if",
"proc-macro-crate",
@@ -3552,7 +3552,7 @@ dependencies = [
[[package]]
name = "ruma-push-gateway-api"
version = "0.9.0"
source = "git+https://github.com/matrix-construct/ruma?rev=a91c1b70fa3cc57fc87a6ce92d2c42a19124a666#a91c1b70fa3cc57fc87a6ce92d2c42a19124a666"
source = "git+https://github.com/matrix-construct/ruma?rev=3d082885f6532cc84ba65ebd2c3ff31b25a7022d#3d082885f6532cc84ba65ebd2c3ff31b25a7022d"
dependencies = [
"js_int",
"ruma-common",
@@ -3564,7 +3564,7 @@ dependencies = [
[[package]]
name = "ruma-signatures"
version = "0.15.0"
source = "git+https://github.com/matrix-construct/ruma?rev=a91c1b70fa3cc57fc87a6ce92d2c42a19124a666#a91c1b70fa3cc57fc87a6ce92d2c42a19124a666"
source = "git+https://github.com/matrix-construct/ruma?rev=3d082885f6532cc84ba65ebd2c3ff31b25a7022d#3d082885f6532cc84ba65ebd2c3ff31b25a7022d"
dependencies = [
"base64",
"ed25519-dalek",

View File

@@ -306,7 +306,7 @@ default-features = false
[workspace.dependencies.ruma]
git = "https://github.com/matrix-construct/ruma"
rev = "a91c1b70fa3cc57fc87a6ce92d2c42a19124a666"
rev = "3d082885f6532cc84ba65ebd2c3ff31b25a7022d"
features = [
"compat",
"rand",

View File

@@ -13,6 +13,8 @@ pub(crate) async fn get_server_version_route(
server: Some(get_server_version::v1::Server {
name: Some(tuwunel_core::version::name().into()),
version: Some(tuwunel_core::version::version().into()),
compiler: tuwunel_core::info::rustc::version().map(Into::into),
..Default::default()
}),
})
}

View File

@@ -10,6 +10,9 @@ use std::{
use crate::utils::exchange;
// Capture rustc version during compilation.
tuwunel_macros::rustc_version! {}
/// Raw capture of rustc flags used to build each crate in the project. Informed
/// by rustc_flags_capture macro (one in each crate's mod.rs). This is
/// done during static initialization which is why it's mutex-protected and pub.
@@ -23,6 +26,16 @@ static FEATURES: OnceLock<Vec<&'static str>> = OnceLock::new();
/// List of features enabled for the project.
pub fn features() -> &'static Vec<&'static str> { FEATURES.get_or_init(init_features) }
/// Version of the rustc compiler used during build.
#[inline]
#[must_use]
pub fn version() -> Option<&'static str> {
RUSTC_VERSION
.len()
.gt(&0)
.then_some(RUSTC_VERSION)
}
fn init_features() -> Vec<&'static str> {
let mut features = Vec::new();
FLAGS

View File

@@ -9,7 +9,8 @@ use std::sync::OnceLock;
static BRANDING: &str = "Tuwunel";
static SEMANTIC: &str = env!("CARGO_PKG_VERSION");
tuwunel_macros::git_describe!();
tuwunel_macros::git_commit! {}
tuwunel_macros::git_semantic! {}
static VERSION: OnceLock<String> = OnceLock::new();
static USER_AGENT: OnceLock<String> = OnceLock::new();
@@ -24,17 +25,36 @@ pub fn version() -> &'static str { VERSION.get_or_init(init_version) }
#[inline]
pub fn user_agent() -> &'static str { USER_AGENT.get_or_init(init_user_agent) }
fn init_user_agent() -> String { format!("{}/{}", name(), version()) }
fn init_user_agent() -> String { format!("{}/{}", name(), semantic()) }
fn init_version() -> String {
option_env!("TUWUNEL_VERSION_EXTRA")
.or(option_env!("CONDUWUIT_VERSION_EXTRA"))
.or(option_env!("CONDUIT_VERSION_EXTRA"))
.map_or(SEMANTIC.to_owned(), |extra| {
if extra.is_empty() {
SEMANTIC.to_owned()
} else {
format!("{SEMANTIC} ({extra})")
}
.map_or_else(detailed, |extra| {
extra
.is_empty()
.then(detailed)
.unwrap_or_else(|| format!("{} ({extra})", detailed()))
})
}
fn detailed() -> String {
let tag_dirty = semantic()
.rsplit_once('-')
.is_some_and(|(_, s)| !s.is_empty());
if !GIT_COMMIT.is_empty() && tag_dirty {
format!("{} ({})", semantic(), GIT_COMMIT)
} else {
semantic().to_owned()
}
}
fn semantic() -> &'static str {
if !GIT_SEMANTIC.is_empty() {
GIT_SEMANTIC
} else {
SEMANTIC
}
}