From 38009319b5d591bd01b3973cc82290e99476fe66 Mon Sep 17 00:00:00 2001 From: Christopher Tam Date: Tue, 31 Dec 2024 01:40:19 -0500 Subject: [PATCH] uplink-sys(build): Fix build script for macOS To get the target build operating system, `CARGO_CFG_TARGET_OS` should be read instead of `cfg(target_os = "macos")`. The latter detects the host OS that is building the `build.rs` script, not the target OS. --- uplink-sys/build.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/uplink-sys/build.rs b/uplink-sys/build.rs index f3c5edb..2c9bb97 100644 --- a/uplink-sys/build.rs +++ b/uplink-sys/build.rs @@ -80,8 +80,10 @@ fn main() { ); // Manually link to core and security libs on MacOS - #[cfg(target_os = "macos")] - { + // + // N.B.: `CARGO_CFG_TARGET_OS` should be read instead of `cfg(target_os = "macos")`. The latter + // detects the host OS that is building the `build.rs` script, not the target OS. + if env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS is not defined") == "macos" { println!("cargo:rustc-flags=-l framework=CoreFoundation -l framework=Security"); }