2017-11-20 12:12:10 +03:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
2017-11-20 12:26:35 +03:00
|
|
|
// The non-CARGO env variables used here must be listed
|
|
|
|
// in build.rs to properly trigger rebuild on change
|
|
|
|
|
2017-11-20 12:12:10 +03:00
|
|
|
pub const PROJECT_NAME: &str = env!("CARGO_PKG_NAME");
|
|
|
|
|
2017-11-30 15:24:13 +03:00
|
|
|
const SOFT_HYPHEN: &str = "\u{00AD}";
|
|
|
|
|
2022-04-03 14:47:43 +03:00
|
|
|
#[cfg(all(not(debug_assertions), feature = "dynamic-assets"))]
|
2018-07-09 22:27:34 +03:00
|
|
|
compile_error!("dynamic-assets must not be used for production");
|
|
|
|
|
2017-11-20 12:12:10 +03:00
|
|
|
lazy_static! {
|
|
|
|
pub static ref VERSION: String = || -> String {
|
2022-04-03 23:03:03 +03:00
|
|
|
let mut components = vec![];
|
2017-11-20 12:12:10 +03:00
|
|
|
|
|
|
|
#[cfg(debug_assertions)]
|
2017-11-20 12:19:49 +03:00
|
|
|
components.push("debug".into());
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
components.push("test".into());
|
|
|
|
|
2022-04-03 14:47:43 +03:00
|
|
|
#[cfg(feature = "dynamic-assets")]
|
2018-07-09 22:27:34 +03:00
|
|
|
components.push("dynamic-assets".into());
|
|
|
|
|
2022-04-03 15:29:35 +03:00
|
|
|
if option_env!("CONTINUOUS_INTEGRATION").is_none() {
|
2017-11-20 12:19:49 +03:00
|
|
|
components.push("local-build".into());
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(branch) = option_env!("TRAVIS_BRANCH") {
|
|
|
|
components.push(format!("branch:{}", branch));
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(commit) = option_env!("TRAVIS_COMMIT") {
|
2022-04-03 14:47:43 +03:00
|
|
|
components.push(format!(
|
|
|
|
"commit:{}",
|
2017-11-30 15:24:13 +03:00
|
|
|
commit
|
|
|
|
.as_bytes()
|
|
|
|
.chunks(4)
|
2022-04-03 14:47:43 +03:00
|
|
|
.map(|x| String::from_utf8(x.to_owned()).unwrap_or_else(|_| String::new()))
|
2017-11-30 15:24:13 +03:00
|
|
|
.collect::<Vec<_>>()
|
|
|
|
.join(SOFT_HYPHEN)
|
|
|
|
));
|
2017-11-20 12:19:49 +03:00
|
|
|
}
|
2017-11-20 12:12:10 +03:00
|
|
|
|
2022-04-03 15:29:35 +03:00
|
|
|
if !components.is_empty() {
|
2017-11-20 12:12:10 +03:00
|
|
|
format!("{} ({})", env!("CARGO_PKG_VERSION"), components.join(" "))
|
|
|
|
} else {
|
|
|
|
env!("CARGO_PKG_VERSION").to_string()
|
|
|
|
}
|
|
|
|
}();
|
2022-04-03 14:47:43 +03:00
|
|
|
pub static ref HTTP_SERVER: String = format!("{}/{}", PROJECT_NAME, VERSION.as_str());
|
2017-11-20 12:12:10 +03:00
|
|
|
}
|