Conditional compilation for debug/release

You can use the following build script

use std::env;

pub fn main() {
    if let Ok(profile) = env::var("PROFILE") {
        println!("cargo:rustc-cfg=build={:?}", profile);
    }
}
7 Likes