//! macOS: embed an Info.plist (`__TEXT,__info_plist`). The copy inside Kestrove.app is signed sandboxed, and the //! sandbox refuses to start an executable without a bundle identifier. `KV_NMH_BUNDLE_ID` is set by //! scripts/build-apple.sh to the app's bundle id + ".nmh"; codesign takes the signing identifier from it. use std::env; use std::fs; use std::path::PathBuf; fn main() { println!("cargo:rerun-if-env-changed=KV_NMH_BUNDLE_ID"); if env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("macos") { return; } let id = env::var("KV_NMH_BUNDLE_ID").unwrap_or_else(|_| "app.kestrove.nmh".into()); assert!( !id.is_empty() && id.chars().all(|c| c.is_ascii_alphanumeric() || c == '.' || c == '-'), "KV_NMH_BUNDLE_ID must be a reverse-DNS identifier" ); let plist = format!( r#" CFBundleIdentifier {id} CFBundleName kestrove-nmh CFBundleInfoDictionaryVersion 6.0 CFBundleShortVersionString {version} "#, version = env::var("CARGO_PKG_VERSION").unwrap() ); let out = PathBuf::from(env::var("OUT_DIR").unwrap()).join("Info.plist"); fs::write(&out, plist).unwrap(); println!("cargo:rustc-link-arg-bins=-Wl,-sectcreate,__TEXT,__info_plist,{}", out.display()); }