2022-02-20 03:43:38 +01:00
|
|
|
use std::path::PathBuf;
|
2022-10-01 08:08:51 +02:00
|
|
|
use std::{env, fs};
|
2022-02-20 03:43:38 +01:00
|
|
|
|
2023-03-06 04:57:21 +01:00
|
|
|
use base64::{engine::general_purpose, Engine as _};
|
|
|
|
|
2022-02-20 03:43:38 +01:00
|
|
|
fn main() {
|
|
|
|
println!("cargo:rerun-if-env-changed=KANIDM_BUILD_PROFILE");
|
|
|
|
|
|
|
|
let profile = env::var("KANIDM_BUILD_PROFILE").unwrap_or_else(|_| "developer".to_string());
|
|
|
|
|
|
|
|
let profile_path: PathBuf = ["./", format!("{}.toml", profile).as_str()]
|
|
|
|
.iter()
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
let data =
|
|
|
|
fs::read(&profile_path).unwrap_or_else(|_| panic!("Failed to read {:?}", profile_path));
|
|
|
|
|
2023-03-06 04:57:21 +01:00
|
|
|
let contents = general_purpose::STANDARD.encode(data);
|
2022-02-20 03:43:38 +01:00
|
|
|
|
|
|
|
println!("cargo:rerun-if-changed={}", profile_path.to_str().unwrap());
|
|
|
|
|
|
|
|
println!("cargo:rustc-env=KANIDM_BUILD_PROFILE={}", profile);
|
|
|
|
println!("cargo:rustc-env=KANIDM_BUILD_PROFILE_TOML={}", contents);
|
|
|
|
}
|