Skip to content

Commit

Permalink
uplink-sys(build): Fix build script for macOS
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
GodTamIt authored and ifraixedes committed Dec 31, 2024
1 parent 857164e commit 3800931
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions uplink-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down

0 comments on commit 3800931

Please sign in to comment.