veloren_common/util/
mod.rs1mod color;
2pub mod dir;
3pub mod find_dist;
4mod grid_hasher;
5pub mod lines;
6mod option;
7pub mod plane;
8pub mod projection;
9mod spatial_grid;
12
13pub const GIT_VERSION_BUILD: &str = include_str!(concat!(env!("OUT_DIR"), "/githash"));
14pub const GIT_TAG_BUILD: &str = include_str!(concat!(env!("OUT_DIR"), "/gittag"));
15pub const VELOREN_VERSION_STAGE: &str = "Pre-Alpha";
16
17lazy_static::lazy_static! {
18 pub static ref GIT_VERSION: String =
19 std::env::var("VELOREN_GIT_VERSION").unwrap_or_else(|_| GIT_VERSION_BUILD.to_string());
20 pub static ref GIT_TAG: String =
21 std::env::var("VELOREN_GIT_TAG").unwrap_or_else(|_| GIT_TAG_BUILD.to_string());
22 pub static ref GIT_HASH: &'static str = GIT_VERSION.split('/').next().expect("failed to retrieve git_hash!");
23 static ref GIT_DATETIME: &'static str = GIT_VERSION.split('/').nth(1).expect("failed to retrieve git_datetime!");
24 pub static ref GIT_DATE: String = GIT_DATETIME.split('-').take(3).collect::<Vec<&str>>().join("-");
25 pub static ref GIT_TIME: &'static str = GIT_DATETIME.split('-').nth(3).expect("failed to retrieve git_time!");
26 pub static ref GIT_DATE_TIMESTAMP: i64 =
27 NaiveDateTime::parse_from_str(*GIT_DATETIME, "%Y-%m-%d-%H:%M")
28 .expect("Invalid date")
29 .and_utc().timestamp();
30 pub static ref DISPLAY_VERSION: String = if GIT_TAG.is_empty() {
31 format!("{}-{}", VELOREN_VERSION_STAGE, *GIT_DATE)
32 } else {
33 format!("{}-{}", VELOREN_VERSION_STAGE, GIT_TAG.as_str())
34 };
35 pub static ref DISPLAY_VERSION_LONG: String = if GIT_TAG.is_empty() {
36 format!("{} ({})", DISPLAY_VERSION.as_str(), *GIT_HASH)
37 } else {
38 format!("{} ({})", DISPLAY_VERSION.as_str(), GIT_VERSION.as_str())
39 };
40}
41
42use chrono::NaiveDateTime;
43pub use color::*;
44pub use dir::*;
45pub use grid_hasher::GridHasher;
46pub use option::either_with;
47pub use plane::Plane;
48pub use projection::Projection;
49pub use spatial_grid::SpatialGrid;