blob: e91df463e74ec51b81a7b805634a3e2627c725da [file] [log] [blame]
Laura Abbottbb8c8d12020-02-24 15:04:54 -05001use std::env;
2
3fn main() {
4 static APP_HEAP_SIZE: &str = "APP_HEAP_SIZE";
5
6 println!("cargo:rerun-if-env-changed={}", APP_HEAP_SIZE);
7
8 set_default_env(APP_HEAP_SIZE, "1024");
9}
10
11fn set_default_env(env_var: &str, default: &str) {
12 if let Some(s) = read_env_var(env_var) {
13 println!("cargo:rustc-env={}={}", env_var, s);
14 } else {
15 // Just use a default of 1024 if nothing is passed in
16 println!("cargo:rustc-env={}={}", env_var, default);
17 }
18}
19
20fn read_env_var(env_var: &str) -> Option<String> {
21 env::var_os(env_var).map(|os_string| os_string.into_string().unwrap())
22}