From 90191a558f93ce81a0d6943b5a7caadfca321650 Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Wed, 15 May 2024 13:54:33 -0400 Subject: [PATCH] Readded features in full_version --- limitador-server/build.rs | 9 +++++++++ limitador-server/src/main.rs | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/limitador-server/build.rs b/limitador-server/build.rs index f7a0d811..9700c93b 100644 --- a/limitador-server/build.rs +++ b/limitador-server/build.rs @@ -6,6 +6,7 @@ use std::process::Command; fn main() -> Result<(), Box> { set_git_hash("LIMITADOR_GIT_HASH"); set_profile("LIMITADOR_PROFILE"); + set_features("LIMITADOR_FEATURES"); generate_protobuf() } @@ -31,6 +32,14 @@ fn set_profile(env: &str) { } } +fn set_features(env: &str) { + let mut features = vec![]; + if cfg!(feature = "distributed_storage") { + features.push("+distributed"); + } + println!("cargo:rustc-env={env}={features:?}"); +} + fn set_git_hash(env: &str) { let git_sha = Command::new("/usr/bin/git") .args(["rev-parse", "HEAD"]) diff --git a/limitador-server/src/main.rs b/limitador-server/src/main.rs index f04e4fa9..a4ced111 100644 --- a/limitador-server/src/main.rs +++ b/limitador-server/src/main.rs @@ -61,6 +61,7 @@ pub mod prometheus_metrics; const LIMITADOR_VERSION: &str = env!("CARGO_PKG_VERSION"); const LIMITADOR_PROFILE: &str = env!("LIMITADOR_PROFILE"); +const LIMITADOR_FEATURES: &str = env!("LIMITADOR_FEATURES"); const LIMITADOR_HEADER: &str = "Limitador Server"; #[derive(Error, Debug)] @@ -370,12 +371,12 @@ async fn main() -> Result<(), Box> { fn create_config() -> (Configuration, &'static str) { let full_version: &'static str = formatcp!( - "v{} ({}) {}", + "v{} ({}) {} {}", LIMITADOR_VERSION, env!("LIMITADOR_GIT_HASH"), + LIMITADOR_FEATURES, LIMITADOR_PROFILE, ); - // wire args based of defaults let limit_arg = Arg::new("LIMITS_FILE") .action(ArgAction::Set)