//! Build script for car-voice.
//!
//! On macOS, embeds `Info.plist.smoke` into example binaries via
//! `-sectcreate __TEXT __info_plist <path>`. macOS' Speech framework
//! and other privacy-gated APIs use `NSBundle.main.bundleIdentifier`
//! to look up on-device assets and TCC entitlements; without an
//! Info.plist the framework falls back to an "unstable" placeholder
//! that can't resolve assets, causing recognition to silently fail
//! within ~80 ms (Apple bug FB-?, observed on macOS 26.4.1 / M5 Pro).
//!
//! `cargo:rustc-link-arg-examples=` applies the linker args to every
//! example target in this crate but not to the lib or to downstream
//! consumers (host apps ship their own Info.plist via Xcode's bundle
//! infrastructure). This keeps the workaround scoped to the smoke
//! tests where it's needed.

fn main() {
    if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("macos") {
        let manifest =
            std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("Info.plist.smoke");
        println!("cargo:rerun-if-changed=Info.plist.smoke");
        println!("cargo:rerun-if-changed=build.rs");
        println!(
            "cargo:rustc-link-arg-examples=-Wl,-sectcreate,__TEXT,__info_plist,{}",
            manifest.display()
        );
    }
}
