From b2e21699ef97162951789c4fa34be1169500b4f0 Mon Sep 17 00:00:00 2001 From: BlackHoleFox Date: Fri, 24 Jun 2022 03:25:02 -0500 Subject: [PATCH 1/2] build: ignore ObjC deprecation warnings --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 8a3551f..cc2e07a 100644 --- a/build.rs +++ b/build.rs @@ -5,7 +5,7 @@ fn main() { cc::Build::new() .file("objc/notify.m") .flag("-fmodules") - .warnings(false) + .flag("-Wno-deprecated-declarations") .compile("notify"); } } From 41cc09753b6802c7061ca8c2c7f226f131158dbe Mon Sep 17 00:00:00 2001 From: BlackHoleFox Date: Sat, 16 Jul 2022 23:06:00 -0500 Subject: [PATCH 2/2] fix: Always pass a macOS deployment version to cc --- build.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/build.rs b/build.rs index cc2e07a..72f7559 100644 --- a/build.rs +++ b/build.rs @@ -1,11 +1,29 @@ extern crate cc; +use std::env; + +const DEPLOYMENT_TARGET_VAR: &str = "MACOSX_DEPLOYMENT_TARGET"; fn main() { if cfg!(target_os = "macos") { + let min_version = match env::var(DEPLOYMENT_TARGET_VAR) { + Ok(ver) => ver, + Err(_) => String::from(match env::var("CARGO_CFG_TARGET_ARCH").unwrap().as_str() { + "x86_64" => "10.8", // NSUserNotificationCenter first showed up here. + "aarch64" => "11.0", // Apple silicon started here. + arch => panic!("unknown arch: {}", arch), + }), + }; + cc::Build::new() .file("objc/notify.m") .flag("-fmodules") .flag("-Wno-deprecated-declarations") + // `cc` doesn't try to pick up on this automatically, but `clang` needs it to + // generate a "correct" Objective-C symbol table which better matches XCode. + // See https://github.com/h4llow3En/mac-notification-sys/issues/45. + .flag(&format!("-mmacos-version-min={}", min_version)) .compile("notify"); + + println!("cargo:rerun-if-env-changed={}", DEPLOYMENT_TARGET_VAR); } }