use std::env; use std::fs; use std::path::PathBuf; fn main() { if env::var_os("CARGO_FEATURE_RT").is_some() { let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); println!("cargo:rustc-link-search={}", out.display()); let device_file = if env::var_os("CARGO_FEATURE_N32G401").is_some() { "src/n32g401/device.x" } else if env::var_os("CARGO_FEATURE_N32G430").is_some() { "src/n32g430/device.x" } else if env::var_os("CARGO_FEATURE_N32G432").is_some() { "src/n32g432/device.x" } else if env::var_os("CARGO_FEATURE_N32G435").is_some() { "src/n32g435/device.x" } else if env::var_os("CARGO_FEATURE_N32G451").is_some() { "src/n32g451/device.x" } else if env::var_os("CARGO_FEATURE_N32G452").is_some() { "src/n32g452/device.x" } else if env::var_os("CARGO_FEATURE_N32G455").is_some() { "src/n32g455/device.x" } else if env::var_os("CARGO_FEATURE_N32G457").is_some() { "src/n32g457/device.x" } else if env::var_os("CARGO_FEATURE_N32G4FR").is_some() { "src/n32g4fr/device.x" } else { panic!("No device features selected"); }; fs::copy(device_file, out.join("device.x")).unwrap(); println!("cargo:rerun-if-changed={}", device_file); } println!("cargo:rerun-if-changed=build.rs"); }