diff --git a/frb_rust/src/codec/dco.rs b/frb_rust/src/codec/dco.rs index efbf847d81..032525e8fb 100644 --- a/frb_rust/src/codec/dco.rs +++ b/frb_rust/src/codec/dco.rs @@ -42,18 +42,18 @@ impl Rust2DartMessageTrait for Rust2DartMessageDco { } unsafe fn from_raw_wire_sync(raw: Self::WireSyncRust2DartType) -> Self { - #[cfg(not(wasm))] + #[cfg(not(target_family = "wasm"))] return Self(*crate::for_generated::box_from_leak_ptr(raw)); - #[cfg(wasm)] + #[cfg(target_family = "wasm")] return Self(raw); } fn into_raw_wire_sync(self) -> Self::WireSyncRust2DartType { - #[cfg(not(wasm))] + #[cfg(not(target_family = "wasm"))] return crate::for_generated::new_leak_box_ptr(self.0); - #[cfg(wasm)] + #[cfg(target_family = "wasm")] return self.0; } } @@ -78,7 +78,7 @@ where #[cfg(test)] mod tests { - #[cfg(not(wasm))] + #[cfg(not(target_family = "wasm"))] #[test] fn test_simplest() { use crate::codec::Rust2DartMessageTrait; diff --git a/frb_rust/src/codec/sse.rs b/frb_rust/src/codec/sse.rs index 4cb5311a40..e5d701ce1d 100644 --- a/frb_rust/src/codec/sse.rs +++ b/frb_rust/src/codec/sse.rs @@ -63,24 +63,24 @@ impl Rust2DartMessageTrait for Rust2DartMessageSse { } unsafe fn from_raw_wire_sync(raw: Self::WireSyncRust2DartType) -> Self { - #[cfg(not(wasm))] + #[cfg(not(target_family = "wasm"))] { let WireSyncRust2DartSse { ptr, len } = raw; Self(crate::for_generated::vec_from_leak_ptr(ptr, len)) } - #[cfg(wasm)] + #[cfg(target_family = "wasm")] Self(js_sys::Uint8Array::new(&raw).to_vec()) } fn into_raw_wire_sync(self) -> Self::WireSyncRust2DartType { - #[cfg(not(wasm))] + #[cfg(not(target_family = "wasm"))] { let (ptr, len) = crate::for_generated::into_leak_vec_ptr(self.0); WireSyncRust2DartSse { ptr, len } } - #[cfg(wasm)] + #[cfg(target_family = "wasm")] return ::from(self.0.as_slice()).into(); } } @@ -101,9 +101,9 @@ impl Dart2RustMessageSse { rust_vec_len: i32, data_len: i32, ) -> Self { - #[cfg(not(wasm))] + #[cfg(not(target_family = "wasm"))] let vec = crate::for_generated::vec_from_leak_ptr(ptr, rust_vec_len); - #[cfg(wasm)] + #[cfg(target_family = "wasm")] let vec = js_sys::Uint8Array::new(&ptr).to_vec(); Self { vec, data_len } diff --git a/frb_rust/src/dart_opaque/boxes/mod.rs b/frb_rust/src/dart_opaque/boxes/mod.rs index 01c84d2159..7fd7097b8f 100644 --- a/frb_rust/src/dart_opaque/boxes/mod.rs +++ b/frb_rust/src/dart_opaque/boxes/mod.rs @@ -1,4 +1,4 @@ -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] pub(crate) mod dart_isolate_box; pub(crate) mod guarded_box; pub(crate) mod thread_box; diff --git a/frb_rust/src/dart_opaque/boxes/thread_box.rs b/frb_rust/src/dart_opaque/boxes/thread_box.rs index 2e871bc388..b490004873 100644 --- a/frb_rust/src/dart_opaque/boxes/thread_box.rs +++ b/frb_rust/src/dart_opaque/boxes/thread_box.rs @@ -50,7 +50,7 @@ impl GuardedBoxContext for GuardedBoxContextThread { } } -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] #[cfg(test)] mod tests { use crate::dart_opaque::boxes::thread_box::ThreadBox; diff --git a/frb_rust/src/dart_opaque/dart2rust.rs b/frb_rust/src/dart_opaque/dart2rust.rs index 813b319da0..faf20c73af 100644 --- a/frb_rust/src/dart_opaque/dart2rust.rs +++ b/frb_rust/src/dart_opaque/dart2rust.rs @@ -1,12 +1,12 @@ use super::{DartOpaque, GeneralizedDartHandle}; use crate::platform_types::{message_port_to_handle, MessagePort}; -#[cfg(wasm)] +#[cfg(target_family = "wasm")] use wasm_bindgen::prelude::*; /// # Safety /// /// This should never be called manually. -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub unsafe fn cst_decode_dart_opaque(raw: wasm_bindgen::JsValue) -> DartOpaque { #[cfg(target_pointer_width = "64")] { @@ -19,7 +19,7 @@ pub unsafe fn cst_decode_dart_opaque(raw: wasm_bindgen::JsValue) -> DartOpaque { /// # Safety /// /// This should never be called manually. -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] pub unsafe fn cst_decode_dart_opaque(raw: usize) -> DartOpaque { DartOpaque::from_raw(raw as _) } @@ -34,7 +34,7 @@ pub unsafe fn sse_decode_dart_opaque(raw: usize) -> DartOpaque { /// # Safety /// /// This should never be called manually. -#[cfg(wasm)] +#[cfg(target_family = "wasm")] #[wasm_bindgen] pub unsafe fn dart_opaque_dart2rust_encode( handle: GeneralizedDartHandle, @@ -46,7 +46,7 @@ pub unsafe fn dart_opaque_dart2rust_encode( /// # Safety /// /// This should never be called manually. -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] #[no_mangle] pub unsafe extern "C" fn dart_opaque_dart2rust_encode( handle: GeneralizedDartHandle, diff --git a/frb_rust/src/dart_opaque/mod.rs b/frb_rust/src/dart_opaque/mod.rs index eb8218c7c6..0f8f7efb55 100644 --- a/frb_rust/src/dart_opaque/mod.rs +++ b/frb_rust/src/dart_opaque/mod.rs @@ -2,18 +2,18 @@ use crate::platform_types::SendableMessagePortHandle; use std::sync::Arc; /// cbindgen:ignore -#[cfg(wasm)] +#[cfg(target_family = "wasm")] mod web; -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub use web::*; -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] mod io; -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] pub use io::*; -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] mod auto_drop_dart_persistent_handle; pub(crate) mod action; diff --git a/frb_rust/src/dart_opaque/non_clone.rs b/frb_rust/src/dart_opaque/non_clone.rs index 5385d7155d..89b477f410 100644 --- a/frb_rust/src/dart_opaque/non_clone.rs +++ b/frb_rust/src/dart_opaque/non_clone.rs @@ -7,7 +7,7 @@ use crate::generalized_isolate::Channel; use crate::generalized_isolate::IntoDart; use crate::misc::logs::log_warn_or_println; use crate::platform_types::{handle_to_message_port, SendableMessagePortHandle}; -#[cfg(wasm)] +#[cfg(target_family = "wasm")] use wasm_bindgen::prelude::*; #[derive(Debug)] @@ -91,13 +91,13 @@ fn drop_thread_box_persistent_handle_via_port( }; } -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] #[no_mangle] pub unsafe extern "C" fn dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { dart_opaque_drop_thread_box_persistent_handle_inner(ptr) } -#[cfg(wasm)] +#[cfg(target_family = "wasm")] #[wasm_bindgen] pub unsafe extern "C" fn dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { dart_opaque_drop_thread_box_persistent_handle_inner(ptr) diff --git a/frb_rust/src/dart_opaque/rust2dart.rs b/frb_rust/src/dart_opaque/rust2dart.rs index 3b70e7bf8d..fd582423e5 100644 --- a/frb_rust/src/dart_opaque/rust2dart.rs +++ b/frb_rust/src/dart_opaque/rust2dart.rs @@ -1,7 +1,7 @@ use super::{DartOpaque, GeneralizedDartHandle}; use crate::generalized_isolate::IntoDart; use crate::platform_types::DartAbi; -#[cfg(wasm)] +#[cfg(target_family = "wasm")] use wasm_bindgen::prelude::*; impl From for DartAbi { @@ -16,13 +16,13 @@ impl DartOpaque { } } -#[cfg(wasm)] +#[cfg(target_family = "wasm")] #[wasm_bindgen] pub unsafe fn dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { dart_opaque_rust2dart_decode_inner(ptr) } -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] #[no_mangle] pub unsafe extern "C" fn dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { dart_opaque_rust2dart_decode_inner(ptr) diff --git a/frb_rust/src/ffi_binding/mod.rs b/frb_rust/src/ffi_binding/mod.rs index 408d11fc35..7456d4bb8f 100644 --- a/frb_rust/src/ffi_binding/mod.rs +++ b/frb_rust/src/ffi_binding/mod.rs @@ -1,14 +1,14 @@ use crate::for_generated::{into_leak_vec_ptr, new_leak_vec_ptr, vec_from_leak_ptr}; -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] mod io; -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] #[allow(unused)] pub use io::*; -#[cfg(wasm)] +#[cfg(target_family = "wasm")] mod web; -#[cfg(wasm)] +#[cfg(target_family = "wasm")] #[allow(unused)] pub use web::*; diff --git a/frb_rust/src/for_generated/cast.rs b/frb_rust/src/for_generated/cast.rs index ab19908872..0f180c4696 100644 --- a/frb_rust/src/for_generated/cast.rs +++ b/frb_rust/src/for_generated/cast.rs @@ -1,6 +1,6 @@ /// Cast a byte buffer into a boxed slice of the target type without making any copies. /// Panics if the cast fails. -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub fn slice_from_byte_buffer(buffer: Vec) -> Box<[T]> { let buf = Box::leak(buffer.into_boxed_slice()); match bytemuck::try_cast_slice_mut(buf) { diff --git a/frb_rust/src/for_generated/mod.rs b/frb_rust/src/for_generated/mod.rs index 4417ca2944..49fbf1441b 100644 --- a/frb_rust/src/for_generated/mod.rs +++ b/frb_rust/src/for_generated/mod.rs @@ -41,7 +41,7 @@ pub use crate::lockable::{ #[allow(unused)] pub use crate::misc::manual_impl::*; pub use crate::misc::version::FLUTTER_RUST_BRIDGE_RUNTIME_VERSION; -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub use crate::misc::web_utils; pub use crate::platform_types::{ DartAbi, MessagePort, PlatformGeneralizedUint8ListPtr, WireSyncRust2DartDco, @@ -63,23 +63,23 @@ pub use crate::rust_auto_opaque::{inner::RustAutoOpaqueInner, RustAutoOpaqueBase pub use crate::rust_opaque::{dart2rust::decode_rust_opaque_nom, RustOpaqueBase}; pub use crate::stream::stream_sink::StreamSinkBase; pub use crate::thread_pool::{BaseThreadPool, SimpleThreadPool}; -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub use crate::web_transfer::transfer_closure::TransferClosure; #[cfg(feature = "anyhow")] pub use anyhow; pub use byteorder; -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub use cast::slice_from_byte_buffer; #[cfg(feature = "dart-opaque")] -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] pub use dart_sys_fork as dart_sys; #[cfg(feature = "rust-async")] pub use futures; -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub use js_sys; pub use lazy_static::lazy_static; #[cfg(feature = "rust-async")] pub use misc_rust_async::*; pub use pointer::*; -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub use wasm_bindgen; diff --git a/frb_rust/src/generalized_isolate/mod.rs b/frb_rust/src/generalized_isolate/mod.rs index 45760da23d..f81a28f14d 100644 --- a/frb_rust/src/generalized_isolate/mod.rs +++ b/frb_rust/src/generalized_isolate/mod.rs @@ -1,10 +1,10 @@ /// cbindgen:ignore -#[cfg(wasm)] +#[cfg(target_family = "wasm")] mod web; -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub use web::*; -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] mod io; -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] pub use io::*; diff --git a/frb_rust/src/handler/handler.rs b/frb_rust/src/handler/handler.rs index 9e5852a5de..1f5d73cd4e 100644 --- a/frb_rust/src/handler/handler.rs +++ b/frb_rust/src/handler/handler.rs @@ -87,14 +87,14 @@ pub enum FfiCallMode { Sync, } -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] pub trait TaskRetFutTrait: Send {} -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] impl TaskRetFutTrait for T {} -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub trait TaskRetFutTrait {} -#[cfg(wasm)] +#[cfg(target_family = "wasm")] impl TaskRetFutTrait for T {} // Originally there were things for StreamSink, but it was moved, so now it is empty diff --git a/frb_rust/src/misc/manual_impl.rs b/frb_rust/src/misc/manual_impl.rs index 48e319499c..2ad1e2ff56 100644 --- a/frb_rust/src/misc/manual_impl.rs +++ b/frb_rust/src/misc/manual_impl.rs @@ -1,9 +1,9 @@ #[cfg(feature = "chrono")] #[inline] pub fn decode_timestamp(ts: i64) -> Timestamp { - #[cfg(wasm)] + #[cfg(target_family = "wasm")] const PRECISION: i64 = 1_000; - #[cfg(not(wasm))] + #[cfg(not(target_family = "wasm"))] const PRECISION: i64 = 1_000_000; let s = ts / PRECISION; @@ -53,7 +53,7 @@ pub fn decode_uuid(id: Vec) -> uuid::Uuid { mod tests { #[test] fn test_decode_timestamp() { - #[cfg(not(wasm))] + #[cfg(not(target_family = "wasm"))] { // input in microseconds let input: i64 = 3_496_567_123; @@ -62,7 +62,7 @@ mod tests { assert_eq!(ns, 567_123_000); } - #[cfg(wasm)] + #[cfg(target_family = "wasm")] { // input in milliseconds let input: i64 = 3_496_567; diff --git a/frb_rust/src/misc/user_utils.rs b/frb_rust/src/misc/user_utils.rs index a31611a150..f7e654eba3 100644 --- a/frb_rust/src/misc/user_utils.rs +++ b/frb_rust/src/misc/user_utils.rs @@ -10,7 +10,7 @@ pub fn setup_default_user_utils() { } fn setup_backtrace() { - #[cfg(not(wasm))] + #[cfg(not(target_family = "wasm"))] if std::env::var("RUST_BACKTRACE").err() == Some(std::env::VarError::NotPresent) { std::env::set_var("RUST_BACKTRACE", "1"); } else { @@ -33,7 +33,7 @@ fn setup_log_to_console() { .level_filter(log::LevelFilter::Trace) .init(); - #[cfg(wasm)] + #[cfg(target_family = "wasm")] let _ = crate::misc::web_utils::WebConsoleLogger::init(); // TODO add more platforms diff --git a/frb_rust/src/platform_types/mod.rs b/frb_rust/src/platform_types/mod.rs index 45760da23d..f81a28f14d 100644 --- a/frb_rust/src/platform_types/mod.rs +++ b/frb_rust/src/platform_types/mod.rs @@ -1,10 +1,10 @@ /// cbindgen:ignore -#[cfg(wasm)] +#[cfg(target_family = "wasm")] mod web; -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub use web::*; -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] mod io; -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] pub use io::*; diff --git a/frb_rust/src/rust_async/mod.rs b/frb_rust/src/rust_async/mod.rs index 6b7c6deccb..e4b31df02a 100644 --- a/frb_rust/src/rust_async/mod.rs +++ b/frb_rust/src/rust_async/mod.rs @@ -1,15 +1,15 @@ #[cfg(feature = "rust-async")] -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] mod io; #[cfg(feature = "rust-async")] -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] pub use io::*; #[cfg(feature = "rust-async")] -#[cfg(wasm)] +#[cfg(target_family = "wasm")] mod web; #[cfg(feature = "rust-async")] -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub use web::*; #[cfg(not(feature = "rust-async"))] diff --git a/frb_rust/src/rust_auto_opaque/api.rs b/frb_rust/src/rust_auto_opaque/api.rs index a145eed5aa..a4d7c432fd 100644 --- a/frb_rust/src/rust_auto_opaque/api.rs +++ b/frb_rust/src/rust_auto_opaque/api.rs @@ -50,7 +50,7 @@ mod tests { assert_eq!(*opaque.try_write().unwrap(), 42); } - #[cfg(not(wasm))] + #[cfg(not(target_family = "wasm"))] #[tokio::test] async fn test_api_async() { let opaque = RustAutoOpaqueNom::new(42); diff --git a/frb_rust/src/third_party/mod.rs b/frb_rust/src/third_party/mod.rs index 3689e034f5..9addf4b2c6 100644 --- a/frb_rust/src/third_party/mod.rs +++ b/frb_rust/src/third_party/mod.rs @@ -1,2 +1,2 @@ -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub(crate) mod wasm_bindgen; diff --git a/frb_rust/src/thread_pool/mod.rs b/frb_rust/src/thread_pool/mod.rs index dc3c97b302..d8ae5a1e0c 100644 --- a/frb_rust/src/thread_pool/mod.rs +++ b/frb_rust/src/thread_pool/mod.rs @@ -1,15 +1,15 @@ #[cfg(feature = "thread-pool")] -#[cfg(wasm)] +#[cfg(target_family = "wasm")] mod web; #[cfg(feature = "thread-pool")] -#[cfg(wasm)] +#[cfg(target_family = "wasm")] pub use web::*; #[cfg(feature = "thread-pool")] -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] mod io; #[cfg(feature = "thread-pool")] -#[cfg(not(wasm))] +#[cfg(not(target_family = "wasm"))] pub use io::*; #[cfg(not(feature = "thread-pool"))]