1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use std::{env, fmt};

#[derive(Clone, Copy, Debug, PartialEq)]
pub enum BuildConfig {
    Debug,
    Release,
    Profile,
    Performance,
}

impl fmt::Display for BuildConfig {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{:?}", self)
    }
}

pub fn build_config() -> BuildConfig {
    let is_release = env::var("PROFILE").map(|profile| profile == "release").unwrap_or(false);
    if is_release {
        BuildConfig::Profile
    } else {
        BuildConfig::Profile
    }
}

pub fn bintemp_dir() -> String {
    let config = build_config();
    format!("win_x64_vs2017_{}", config)
}

pub fn bin_dir() -> &'static str {
    match build_config() {
        config if config == BuildConfig::Debug => "Bin64vc141.Debug",
        _ => "Bin64vc141",
    }
}

pub fn lmbr_root() -> Result<String, std::env::VarError> {
    std::env::var("LMBR_ROOT").or_else(|_| {
            if cfg!(target_os = "windows") {
                Ok(String::from(r"D:\projects\lumberyard"))
            } else {
                Err(std::env::VarError::NotPresent)
            }
    })
}