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