use std::env;
use std::path::PathBuf;

fn main() {
    println!("cargo:rerun-if-changed=macos/Info.plist");

    let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
    if target_os != "macos" {
        return;
    }

    let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("manifest dir"));
    let plist = manifest_dir.join("macos/Info.plist");
    let arg = format!("-Wl,-sectcreate,__TEXT,__info_plist,{}", plist.display());

    // Ensure all ruin_app executables/examples opt into Retina rendering.
    println!("cargo:rustc-link-arg-examples={arg}");
}
