fix conditional logic that enables native bluetooth (#31073)

PR #30974 integrated `servo/devices` repo into servo
codebase. `servo/devices` exposed the `bluetooth`
feature to conditionally compile native bluetooth
support for the target platform. In servo, this feature
is indirectly enabled via the `native-bluetooth` feature
exposed by `components/bluetooth`. When `servo/devices` was
integrated to servo, the conditional code was not updated
to use the `native-bluetooth` feature directly.

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Mukilan Thiyagarajan 2024-01-12 14:54:39 +05:30 committed by GitHub
parent 6dc208bb09
commit b61c794ae4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 151 additions and 158 deletions

View file

@ -5,15 +5,15 @@
macro_rules! get_inner_and_call(
($enum_value: expr, $enum_type: ident, $function_name: ident) => {
match $enum_value {
#[cfg(all(target_os = "linux", feature = "bluetooth"))]
#[cfg(all(target_os = "linux", feature = "native-bluetooth"))]
&$enum_type::Bluez(ref bluez) => bluez.$function_name(),
#[cfg(all(target_os = "android", feature = "bluetooth"))]
#[cfg(all(target_os = "android", feature = "native-bluetooth"))]
&$enum_type::Android(ref android) => android.$function_name(),
#[cfg(all(target_os = "macos", feature = "bluetooth"))]
#[cfg(all(target_os = "macos", feature = "native-bluetooth"))]
&$enum_type::Mac(ref mac) => mac.$function_name(),
#[cfg(not(any(all(target_os = "linux", feature = "bluetooth"),
all(target_os = "android", feature = "bluetooth"),
all(target_os = "macos", feature = "bluetooth"))))]
#[cfg(not(any(all(target_os = "linux", feature = "native-bluetooth"),
all(target_os = "android", feature = "native-bluetooth"),
all(target_os = "macos", feature = "native-bluetooth"))))]
&$enum_type::Empty(ref empty) => empty.$function_name(),
#[cfg(feature = "bluetooth-test")]
&$enum_type::Mock(ref fake) => fake.$function_name(),
@ -22,15 +22,15 @@ macro_rules! get_inner_and_call(
(@with_bluez_offset, $enum_value: expr, $enum_type: ident, $function_name: ident) => {
match $enum_value {
#[cfg(all(target_os = "linux", feature = "bluetooth"))]
#[cfg(all(target_os = "linux", feature = "native-bluetooth"))]
&$enum_type::Bluez(ref bluez) => bluez.$function_name(None),
#[cfg(all(target_os = "android", feature = "bluetooth"))]
#[cfg(all(target_os = "android", feature = "native-bluetooth"))]
&$enum_type::Android(ref android) => android.$function_name(),
#[cfg(all(target_os = "macos", feature = "bluetooth"))]
#[cfg(all(target_os = "macos", feature = "native-bluetooth"))]
&$enum_type::Mac(ref mac) => mac.$function_name(),
#[cfg(not(any(all(target_os = "linux", feature = "bluetooth"),
all(target_os = "android", feature = "bluetooth"),
all(target_os = "macos", feature = "bluetooth"))))]
#[cfg(not(any(all(target_os = "linux", feature = "native-bluetooth"),
all(target_os = "android", feature = "native-bluetooth"),
all(target_os = "macos", feature = "native-bluetooth"))))]
&$enum_type::Empty(ref empty) => empty.$function_name(),
#[cfg(feature = "bluetooth-test")]
&$enum_type::Mock(ref fake) => fake.$function_name(),
@ -39,15 +39,15 @@ macro_rules! get_inner_and_call(
($enum_value: expr, $enum_type: ident, $function_name: ident, $value: expr) => {
match $enum_value {
#[cfg(all(target_os = "linux", feature = "bluetooth"))]
#[cfg(all(target_os = "linux", feature = "native-bluetooth"))]
&$enum_type::Bluez(ref bluez) => bluez.$function_name($value),
#[cfg(all(target_os = "android", feature = "bluetooth"))]
#[cfg(all(target_os = "android", feature = "native-bluetooth"))]
&$enum_type::Android(ref android) => android.$function_name($value),
#[cfg(all(target_os = "macos", feature = "bluetooth"))]
#[cfg(all(target_os = "macos", feature = "native-bluetooth"))]
&$enum_type::Mac(ref mac) => mac.$function_name($value),
#[cfg(not(any(all(target_os = "linux", feature = "bluetooth"),
all(target_os = "android", feature = "bluetooth"),
all(target_os = "macos", feature = "bluetooth"))))]
#[cfg(not(any(all(target_os = "linux", feature = "native-bluetooth"),
all(target_os = "android", feature = "native-bluetooth"),
all(target_os = "macos", feature = "native-bluetooth"))))]
&$enum_type::Empty(ref empty) => empty.$function_name($value),
#[cfg(feature = "bluetooth-test")]
&$enum_type::Mock(ref fake) => fake.$function_name($value),
@ -56,15 +56,15 @@ macro_rules! get_inner_and_call(
(@with_bluez_offset, $enum_value: expr, $enum_type: ident, $function_name: ident, $value: expr) => {
match $enum_value {
#[cfg(all(target_os = "linux", feature = "bluetooth"))]
#[cfg(all(target_os = "linux", feature = "native-bluetooth"))]
&$enum_type::Bluez(ref bluez) => bluez.$function_name($value, None),
#[cfg(all(target_os = "android", feature = "bluetooth"))]
#[cfg(all(target_os = "android", feature = "native-bluetooth"))]
&$enum_type::Android(ref android) => android.$function_name($value),
#[cfg(all(target_os = "macos", feature = "bluetooth"))]
#[cfg(all(target_os = "macos", feature = "native-bluetooth"))]
&$enum_type::Mac(ref mac) => mac.$function_name($value),
#[cfg(not(any(all(target_os = "linux", feature = "bluetooth"),
all(target_os = "android", feature = "bluetooth"),
all(target_os = "macos", feature = "bluetooth"))))]
#[cfg(not(any(all(target_os = "linux", feature = "native-bluetooth"),
all(target_os = "android", feature = "native-bluetooth"),
all(target_os = "macos", feature = "native-bluetooth"))))]
&$enum_type::Empty(ref empty) => empty.$function_name($value),
#[cfg(feature = "bluetooth-test")]
&$enum_type::Mock(ref fake) => fake.$function_name($value),