diff --git a/io/zenoh-link/src/lib.rs b/io/zenoh-link/src/lib.rs index a561c8ff0c..eda8452d40 100644 --- a/io/zenoh-link/src/lib.rs +++ b/io/zenoh-link/src/lib.rs @@ -72,9 +72,9 @@ use zenoh_link_unixpipe::{ LinkManagerUnicastPipe, UnixPipeConfigurator, UnixPipeLocatorInspector, UNIXPIPE_LOCATOR_PREFIX, }; -#[cfg(feature = "transport_vsock")] +#[cfg(all(feature = "transport_vsock", target_family = "unix"))] pub use zenoh_link_vsock as vsock; -#[cfg(feature = "transport_vsock")] +#[cfg(all(feature = "transport_vsock", target_family = "unix"))] use zenoh_link_vsock::{LinkManagerUnicastVsock, VsockLocatorInspector, VSOCK_LOCATOR_PREFIX}; pub use zenoh_link_commons::*; @@ -97,7 +97,7 @@ pub const PROTOCOLS: &[&str] = &[ serial::SERIAL_LOCATOR_PREFIX, #[cfg(feature = "transport_unixpipe")] unixpipe::UNIXPIPE_LOCATOR_PREFIX, - #[cfg(feature = "transport_vsock")] + #[cfg(all(feature = "transport_vsock", target_family = "unix"))] vsock::VSOCK_LOCATOR_PREFIX, ]; @@ -119,7 +119,7 @@ pub struct LocatorInspector { serial_inspector: SerialLocatorInspector, #[cfg(feature = "transport_unixpipe")] unixpipe_inspector: UnixPipeLocatorInspector, - #[cfg(feature = "transport_vsock")] + #[cfg(all(feature = "transport_vsock", target_family = "unix"))] vsock_inspector: VsockLocatorInspector, } impl LocatorInspector { @@ -146,7 +146,7 @@ impl LocatorInspector { SERIAL_LOCATOR_PREFIX => self.serial_inspector.is_multicast(locator).await, #[cfg(feature = "transport_unixpipe")] UNIXPIPE_LOCATOR_PREFIX => self.unixpipe_inspector.is_multicast(locator).await, - #[cfg(feature = "transport_vsock")] + #[cfg(all(feature = "transport_vsock", target_family = "unix"))] VSOCK_LOCATOR_PREFIX => self.vsock_inspector.is_multicast(locator).await, _ => bail!("Unsupported protocol: {}.", protocol), } @@ -237,7 +237,7 @@ impl LinkManagerBuilderUnicast { UNIXPIPE_LOCATOR_PREFIX => { Ok(std::sync::Arc::new(LinkManagerUnicastPipe::new(_manager))) } - #[cfg(feature = "transport_vsock")] + #[cfg(all(feature = "transport_vsock", target_family = "unix"))] VSOCK_LOCATOR_PREFIX => Ok(std::sync::Arc::new(LinkManagerUnicastVsock::new(_manager))), _ => bail!("Unicast not supported for {} protocol", protocol), } diff --git a/io/zenoh-links/zenoh-link-vsock/src/lib.rs b/io/zenoh-links/zenoh-link-vsock/src/lib.rs index 2e838801d7..59b592d1b2 100644 --- a/io/zenoh-links/zenoh-link-vsock/src/lib.rs +++ b/io/zenoh-links/zenoh-link-vsock/src/lib.rs @@ -19,15 +19,19 @@ //! [Click here for Zenoh's documentation](../zenoh/index.html) use async_trait::async_trait; use libc::VMADDR_PORT_ANY; -use tokio_vsock::{ - VsockAddr, VMADDR_CID_ANY, VMADDR_CID_HOST, VMADDR_CID_HYPERVISOR, VMADDR_CID_LOCAL, -}; use zenoh_core::zconfigurable; use zenoh_link_commons::LocatorInspector; use zenoh_protocol::core::{endpoint::Address, Locator}; use zenoh_result::{bail, ZResult}; +#[cfg(target_family = "unix")] +use tokio_vsock::{ + VsockAddr, VMADDR_CID_ANY, VMADDR_CID_HOST, VMADDR_CID_HYPERVISOR, VMADDR_CID_LOCAL, +}; + +#[cfg(target_family = "unix")] mod unicast; +#[cfg(target_family = "unix")] pub use unicast::*; pub const VSOCK_LOCATOR_PREFIX: &str = "vsock";