openrtc 1.0.1

OpenRTC: a Rust-first P2P runtime for device discovery, signaling, and iroh/QUIC networking.
Documentation
use std::{env, fs, path::PathBuf};

fn main() {
    cfg_aliases::cfg_aliases! {
        // True when compiling for the browser (wasm32 target).
        // Use `#[cfg(browser)]` instead of `#[cfg(target_arch = "wasm32")]`.
        browser: { target_arch = "wasm32" },
        // True when compiling for native (any non-wasm32 target).
        // Use `#[cfg(native)]` instead of `#[cfg(not(target_arch = "wasm32"))]`.
        native: { not(target_arch = "wasm32") },
    }

    println!("cargo:rustc-check-cfg=cfg(openrtc_iroh_preferred_transport_api)");
    println!("cargo:rustc-check-cfg=cfg(openrtc_iroh_relay_transport_policy_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);
    let vendored_relay_transport_policy_api_present = fs::read_to_string(&vendored_endpoint)
        .map(|source| source.contains("pub fn relay_transport_policy"))
        .unwrap_or(false);

    if explicit || vendored_api_present {
        println!("cargo:rustc-cfg=openrtc_iroh_preferred_transport_api");
    }
    if vendored_relay_transport_policy_api_present {
        println!("cargo:rustc-cfg=openrtc_iroh_relay_transport_policy_api");
    }
}