From 71bf9fb92d8292d7d26367da4c4d421d25bf9a07 Mon Sep 17 00:00:00 2001 From: Rodion Borovyk Date: Mon, 16 Jun 2025 08:58:08 +0200 Subject: [PATCH] Fix the native-bluetooth feature on macOS (#37476) Fix the native-bluetooth feature on macOS builds. Enable the native-bluetooth by default. Testing: Added --features native-bluetooth to GH actions so the build will fail if something is wrong. Don't know why it was not enabled previously, please let me know if it is ok to leave the feature enabled. Fixes: https://github.com/servo/servo/issues/37454 As for the numerous such warnings ``` warning: unexpected `cfg` condition value: `cargo-clippy` --> third_party/blurmac/src/framework.rs:480:43 | 480 | let uuidstring: *mut Object = msg_send![cbuuid, UUIDString]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: no expected values for `feature` = note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate = help: try referring to `sel_impl` crate for guidance on how handle this unexpected cfg = help: the macro `sel_impl` may come from an old version of the `objc` crate, try updating your dependency with `cargo update -p objc` = note: see for more information about checking conditional configuration = note: this warning originates in the macro `sel_impl` which comes from the expansion of the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info) ``` that macOS builds generates (mentioned [here](https://github.com/servo/servo/pull/37439)) I found this: https://github.com/SSheldon/rust-objc/issues/125. Also, in general the `objc` crate seems to be stale and people are forking it, so maybe I should start a Zulip conversation about migrating to something like this https://github.com/madsmtm/objc2? --------- Signed-off-by: Rodion Borovyk --- third_party/blurmac/src/adapter.rs | 7 ++++--- third_party/blurmac/src/delegate.rs | 5 +++-- third_party/blurmac/src/device.rs | 9 +++++---- third_party/blurmac/src/discovery_session.rs | 2 +- third_party/blurmac/src/gatt_characteristic.rs | 9 +++++---- third_party/blurmac/src/gatt_descriptor.rs | 2 +- third_party/blurmac/src/gatt_service.rs | 9 +++++---- third_party/blurmac/src/utils.rs | 3 ++- 8 files changed, 26 insertions(+), 20 deletions(-) diff --git a/third_party/blurmac/src/adapter.rs b/third_party/blurmac/src/adapter.rs index e51b90345a1..59f0ddfb25a 100644 --- a/third_party/blurmac/src/adapter.rs +++ b/third_party/blurmac/src/adapter.rs @@ -8,10 +8,11 @@ use std::error::Error; use std::os::raw::c_int; -use delegate::bm; -use framework::{cb, io, ns}; use objc::runtime::{Object, YES}; -use utils::{NOT_SUPPORTED_ERROR, nsx}; + +use crate::delegate::bm; +use crate::framework::{cb, io, ns}; +use crate::utils::{NOT_SUPPORTED_ERROR, nsx}; #[derive(Clone, Debug)] pub struct BluetoothAdapter { diff --git a/third_party/blurmac/src/delegate.rs b/third_party/blurmac/src/delegate.rs index 2b97e577dd8..8b59318e021 100644 --- a/third_party/blurmac/src/delegate.rs +++ b/third_party/blurmac/src/delegate.rs @@ -8,10 +8,11 @@ use std::error::Error; use std::sync::Once; -use framework::{cb, nil, ns}; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Protocol, Sel}; -use utils::{NO_PERIPHERAL_FOUND, cbx, nsx, wait}; + +use crate::framework::{cb, nil, ns}; +use crate::utils::{NO_PERIPHERAL_FOUND, cbx, nsx, wait}; pub mod bm { use super::*; diff --git a/third_party/blurmac/src/device.rs b/third_party/blurmac/src/device.rs index 04c48712b2e..9425e7627ed 100644 --- a/third_party/blurmac/src/device.rs +++ b/third_party/blurmac/src/device.rs @@ -9,11 +9,12 @@ use std::collections::HashMap; use std::error::Error; use std::sync::Arc; -use adapter::BluetoothAdapter; -use delegate::{bm, bmx}; -use framework::{cb, nil, ns}; use objc::runtime::Object; -use utils::{NO_PERIPHERAL_FOUND, NOT_SUPPORTED_ERROR, cbx, nsx, wait}; + +use crate::adapter::BluetoothAdapter; +use crate::delegate::{bm, bmx}; +use crate::framework::{cb, nil, ns}; +use crate::utils::{NO_PERIPHERAL_FOUND, NOT_SUPPORTED_ERROR, cbx, nsx, wait}; #[derive(Clone, Debug)] pub struct BluetoothDevice { diff --git a/third_party/blurmac/src/discovery_session.rs b/third_party/blurmac/src/discovery_session.rs index 89da90803f7..bbbd0f2aff2 100644 --- a/third_party/blurmac/src/discovery_session.rs +++ b/third_party/blurmac/src/discovery_session.rs @@ -8,7 +8,7 @@ use std::error::Error; use std::sync::Arc; -use adapter::BluetoothAdapter; +use crate::adapter::BluetoothAdapter; #[derive(Clone, Debug)] pub struct BluetoothDiscoverySession { diff --git a/third_party/blurmac/src/gatt_characteristic.rs b/third_party/blurmac/src/gatt_characteristic.rs index bb2d95097d7..4e582e5c6d6 100644 --- a/third_party/blurmac/src/gatt_characteristic.rs +++ b/third_party/blurmac/src/gatt_characteristic.rs @@ -10,11 +10,12 @@ use std::os::raw::c_uint; use std::slice; use std::sync::Arc; -use delegate::bmx; -use framework::{cb, nil, ns}; -use gatt_service::BluetoothGATTService; use objc::runtime::{NO, Object, YES}; -use utils::{NO_CHARACTERISTIC_FOUND, NOT_SUPPORTED_ERROR, cbx, wait}; + +use crate::delegate::bmx; +use crate::framework::{cb, nil, ns}; +use crate::gatt_service::BluetoothGATTService; +use crate::utils::{NO_CHARACTERISTIC_FOUND, NOT_SUPPORTED_ERROR, cbx, wait}; #[derive(Clone, Debug)] pub struct BluetoothGATTCharacteristic { diff --git a/third_party/blurmac/src/gatt_descriptor.rs b/third_party/blurmac/src/gatt_descriptor.rs index 2a4ce5b7eb3..0b394be2136 100644 --- a/third_party/blurmac/src/gatt_descriptor.rs +++ b/third_party/blurmac/src/gatt_descriptor.rs @@ -7,7 +7,7 @@ use std::error::Error; -use utils::NOT_SUPPORTED_ERROR; +use crate::utils::NOT_SUPPORTED_ERROR; #[derive(Clone, Debug)] pub struct BluetoothGATTDescriptor {} diff --git a/third_party/blurmac/src/gatt_service.rs b/third_party/blurmac/src/gatt_service.rs index cc46544d1e4..33de7e72450 100644 --- a/third_party/blurmac/src/gatt_service.rs +++ b/third_party/blurmac/src/gatt_service.rs @@ -8,11 +8,12 @@ use std::error::Error; use std::sync::Arc; -use delegate::bmx; -use device::BluetoothDevice; -use framework::{cb, nil, ns}; use objc::runtime::Object; -use utils::{NO_SERVICE_FOUND, cbx, wait}; + +use crate::delegate::bmx; +use crate::device::BluetoothDevice; +use crate::framework::{cb, nil, ns}; +use crate::utils::{NO_SERVICE_FOUND, cbx, wait}; #[derive(Clone, Debug)] pub struct BluetoothGATTService { diff --git a/third_party/blurmac/src/utils.rs b/third_party/blurmac/src/utils.rs index a32c002a233..0d0c2bb8985 100644 --- a/third_party/blurmac/src/utils.rs +++ b/third_party/blurmac/src/utils.rs @@ -10,9 +10,10 @@ use std::ffi::{CStr, CString}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::{thread, time}; -use framework::{cb, nil, ns}; use objc::runtime::Object; +use crate::framework::{cb, nil, ns}; + pub const NOT_SUPPORTED_ERROR: &str = "Error! Not supported by blurmac!"; pub const NO_PERIPHERAL_FOUND: &str = "Error! No peripheral found!"; pub const NO_SERVICE_FOUND: &str = "Error! No service found!";