Detailed version string. (closes #62)
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
22
Cargo.lock
generated
22
Cargo.lock
generated
@@ -3384,7 +3384,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma"
|
name = "ruma"
|
||||||
version = "0.10.1"
|
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 = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"js_int",
|
"js_int",
|
||||||
@@ -3404,7 +3404,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-appservice-api"
|
name = "ruma-appservice-api"
|
||||||
version = "0.10.0"
|
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 = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
@@ -3416,7 +3416,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-client-api"
|
name = "ruma-client-api"
|
||||||
version = "0.18.0"
|
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 = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"assign",
|
"assign",
|
||||||
@@ -3439,7 +3439,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-common"
|
name = "ruma-common"
|
||||||
version = "0.13.0"
|
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 = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"base64",
|
"base64",
|
||||||
@@ -3471,7 +3471,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-events"
|
name = "ruma-events"
|
||||||
version = "0.28.1"
|
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 = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
@@ -3496,7 +3496,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-federation-api"
|
name = "ruma-federation-api"
|
||||||
version = "0.9.0"
|
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 = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"headers",
|
"headers",
|
||||||
@@ -3518,7 +3518,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identifiers-validation"
|
name = "ruma-identifiers-validation"
|
||||||
version = "0.9.5"
|
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 = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"thiserror 2.0.12",
|
"thiserror 2.0.12",
|
||||||
@@ -3527,7 +3527,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identity-service-api"
|
name = "ruma-identity-service-api"
|
||||||
version = "0.9.0"
|
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 = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
@@ -3537,7 +3537,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-macros"
|
name = "ruma-macros"
|
||||||
version = "0.13.0"
|
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 = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
@@ -3552,7 +3552,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-push-gateway-api"
|
name = "ruma-push-gateway-api"
|
||||||
version = "0.9.0"
|
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 = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
@@ -3564,7 +3564,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-signatures"
|
name = "ruma-signatures"
|
||||||
version = "0.15.0"
|
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 = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ default-features = false
|
|||||||
|
|
||||||
[workspace.dependencies.ruma]
|
[workspace.dependencies.ruma]
|
||||||
git = "https://github.com/matrix-construct/ruma"
|
git = "https://github.com/matrix-construct/ruma"
|
||||||
rev = "a91c1b70fa3cc57fc87a6ce92d2c42a19124a666"
|
rev = "3d082885f6532cc84ba65ebd2c3ff31b25a7022d"
|
||||||
features = [
|
features = [
|
||||||
"compat",
|
"compat",
|
||||||
"rand",
|
"rand",
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ pub(crate) async fn get_server_version_route(
|
|||||||
server: Some(get_server_version::v1::Server {
|
server: Some(get_server_version::v1::Server {
|
||||||
name: Some(tuwunel_core::version::name().into()),
|
name: Some(tuwunel_core::version::name().into()),
|
||||||
version: Some(tuwunel_core::version::version().into()),
|
version: Some(tuwunel_core::version::version().into()),
|
||||||
|
compiler: tuwunel_core::info::rustc::version().map(Into::into),
|
||||||
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ use std::{
|
|||||||
|
|
||||||
use crate::utils::exchange;
|
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
|
/// 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
|
/// 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.
|
/// 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.
|
/// List of features enabled for the project.
|
||||||
pub fn features() -> &'static Vec<&'static str> { FEATURES.get_or_init(init_features) }
|
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> {
|
fn init_features() -> Vec<&'static str> {
|
||||||
let mut features = Vec::new();
|
let mut features = Vec::new();
|
||||||
FLAGS
|
FLAGS
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ use std::sync::OnceLock;
|
|||||||
|
|
||||||
static BRANDING: &str = "Tuwunel";
|
static BRANDING: &str = "Tuwunel";
|
||||||
static SEMANTIC: &str = env!("CARGO_PKG_VERSION");
|
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 VERSION: OnceLock<String> = OnceLock::new();
|
||||||
static USER_AGENT: 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]
|
#[inline]
|
||||||
pub fn user_agent() -> &'static str { USER_AGENT.get_or_init(init_user_agent) }
|
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 {
|
fn init_version() -> String {
|
||||||
option_env!("TUWUNEL_VERSION_EXTRA")
|
option_env!("TUWUNEL_VERSION_EXTRA")
|
||||||
.or(option_env!("CONDUWUIT_VERSION_EXTRA"))
|
.or(option_env!("CONDUWUIT_VERSION_EXTRA"))
|
||||||
.or(option_env!("CONDUIT_VERSION_EXTRA"))
|
.or(option_env!("CONDUIT_VERSION_EXTRA"))
|
||||||
.map_or(SEMANTIC.to_owned(), |extra| {
|
.map_or_else(detailed, |extra| {
|
||||||
if extra.is_empty() {
|
extra
|
||||||
SEMANTIC.to_owned()
|
.is_empty()
|
||||||
} else {
|
.then(detailed)
|
||||||
format!("{SEMANTIC} ({extra})")
|
.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user