use std::{env, error::Error, fs, path::PathBuf};
use esp_build::assert_unique_used_features;
fn main() -> Result<(), Box<dyn Error>> {
assert_unique_used_features!("esp32c6", "esp32s2", "esp32s3");
let device_name = if cfg!(feature = "esp32c6") {
"esp32c6"
} else if cfg!(feature = "esp32s2") {
"esp32s2"
} else if cfg!(feature = "esp32s3") {
"esp32s3"
} else {
unreachable!() };
println!("cargo:rustc-cfg={}", device_name);
let out = PathBuf::from(env::var_os("OUT_DIR").unwrap());
println!("cargo:rustc-link-search={}", out.display());
if cfg!(feature = "esp32c6") {
fs::copy("ld/link-lp.x", out.join("link.x"))?;
println!("cargo:rerun-if-changed=ld/link-lp.x");
} else if cfg!(feature = "esp32s2") || cfg!(feature = "esp32s3") {
fs::copy("ld/link-ulp.x", out.join("link.x"))?;
println!("cargo:rerun-if-changed=ld/link-ulp.x");
}
Ok(())
}