use anyhow::Result;
use std::collections::HashMap;
use std::path::Path;
pub type EnvMap = HashMap<String, String>;
pub fn build_env(target_dir: Option<&Path>) -> Result<EnvMap> {
let mut env = EnvMap::new();
if let Some(target_dir) = target_dir {
env.insert(
"CARGO_TARGET_DIR".to_string(),
target_dir.to_string_lossy().to_string(),
);
}
if which::which("sccache").is_ok() {
env.insert("RUSTC_WRAPPER".to_string(), "sccache".to_string());
}
env.insert("CARGO_BUILD_DEP_INFO_BASEDIR".to_string(), ".".to_string());
Ok(env)
}