Skip to content

Commit d41d6df

Browse files
feat(libp2p): arch gates *-websys export and dependencies.
This merge request architecture gates *-websys dependencies to wasm in Cargo.toml and does similar arch gating in lib.rs for rexports of *-websys targets. Closes #5885 Pull-Request: #5891.
1 parent f22fec3 commit d41d6df

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

libp2p/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
- Introduce `libp2p-webrtc-websys` behind `webrtc-websys` feature flag.
33
See [PR 5819](https://github.com/libp2p/rust-libp2p/pull/5819).
44

5+
- Make the `*-websys` variants (`libp2p-webrtc-websys`, `libp2p-websocket-websys`, `libp2p-webtransport-websys`) only available on wasm32 target architecture.
6+
See [PR 5891](https://github.com/libp2p/rust-libp2p/pull/5891).
7+
58
## 0.55.0
69

710
- Raise MSRV to 1.83.0.

libp2p/Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` featu
9999
getrandom = { workspace = true } # Explicit dependency to be used in `wasm-bindgen` feature
100100
# TODO feature flag?
101101
rw-stream-sink = { workspace = true }
102-
103102
libp2p-allow-block-list = { workspace = true }
104103
libp2p-autonat = { workspace = true, optional = true }
105104
libp2p-connection-limits = { workspace = true }
@@ -119,14 +118,16 @@ libp2p-relay = { workspace = true, optional = true }
119118
libp2p-rendezvous = { workspace = true, optional = true }
120119
libp2p-request-response = { workspace = true, optional = true }
121120
libp2p-swarm = { workspace = true }
122-
libp2p-webrtc-websys = { workspace = true, optional = true }
123-
libp2p-websocket-websys = { workspace = true, optional = true }
124-
libp2p-webtransport-websys = { workspace = true, optional = true }
125121
libp2p-yamux = { workspace = true, optional = true }
126122
multiaddr = { workspace = true }
127123
pin-project = "1.0.0"
128124
thiserror = { workspace = true }
129125

126+
[target.'cfg(target_arch = "wasm32")'.dependencies]
127+
libp2p-webrtc-websys = { workspace = true, optional = true }
128+
libp2p-websocket-websys = { workspace = true, optional = true }
129+
libp2p-webtransport-websys = { workspace = true, optional = true }
130+
130131
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
131132
libp2p-dns = { workspace = true, optional = true }
132133
libp2p-mdns = { workspace = true, optional = true }

libp2p/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,17 @@ pub use libp2p_uds as uds;
123123
#[cfg(not(target_arch = "wasm32"))]
124124
#[doc(inline)]
125125
pub use libp2p_upnp as upnp;
126-
#[cfg(feature = "webrtc-websys")]
126+
#[cfg(all(feature = "webrtc-websys", target_arch = "wasm32"))]
127127
#[doc(inline)]
128128
pub use libp2p_webrtc_websys as webrtc_websys;
129129
#[cfg(feature = "websocket")]
130130
#[cfg(not(target_arch = "wasm32"))]
131131
#[doc(inline)]
132132
pub use libp2p_websocket as websocket;
133-
#[cfg(feature = "websocket-websys")]
133+
#[cfg(all(feature = "websocket-websys", target_arch = "wasm32"))]
134134
#[doc(inline)]
135135
pub use libp2p_websocket_websys as websocket_websys;
136-
#[cfg(feature = "webtransport-websys")]
136+
#[cfg(all(feature = "webtransport-websys", target_arch = "wasm32"))]
137137
#[cfg_attr(docsrs, doc(cfg(feature = "webtransport-websys")))]
138138
#[doc(inline)]
139139
pub use libp2p_webtransport_websys as webtransport_websys;

0 commit comments

Comments
 (0)