use std::{env, fs, path::PathBuf};
fn main() {
cfg_aliases::cfg_aliases! {
browser: { target_arch = "wasm32" },
native: { not(target_arch = "wasm32") },
}
println!("cargo:rustc-check-cfg=cfg(openrtc_iroh_preferred_transport_api)");
println!("cargo:rerun-if-env-changed=OPENRTC_IROH_PREFERRED_TRANSPORT_API");
let manifest_dir =
PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR"));
let vendored_endpoint = manifest_dir.join("../../vendor/iroh/iroh/src/endpoint.rs");
println!("cargo:rerun-if-changed={}", vendored_endpoint.display());
let explicit = env::var("OPENRTC_IROH_PREFERRED_TRANSPORT_API")
.map(|value| value == "1" || value.eq_ignore_ascii_case("true"))
.unwrap_or(false);
let vendored_api_present = fs::read_to_string(&vendored_endpoint)
.map(|source| source.contains("with_preferred_transport_addr"))
.unwrap_or(false);
if explicit || vendored_api_present {
println!("cargo:rustc-cfg=openrtc_iroh_preferred_transport_api");
}
}