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