Skip to content

Commit

Permalink
refactor: use target_arch instead of target_os for wasm cfg's
Browse files Browse the repository at this point in the history
As far as I can tell, this is equivalent and less verbose.

Pull-Request: #3572.
  • Loading branch information
thomaseizinger authored Mar 10, 2023
1 parent ad02201 commit c06731b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion libp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ libp2p-yamux = { version = "0.43.0", path = "../muxers/yamux", optional = true }
multiaddr = { version = "0.17.0" }
pin-project = "1.0.0"

[target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
libp2p-deflate = { version = "0.39.0", path = "../transports/deflate", optional = true }
libp2p-dns = { version = "0.39.0", path = "../transports/dns", optional = true }
libp2p-mdns = { version = "0.43.0", path = "../protocols/mdns", optional = true }
Expand Down
22 changes: 11 additions & 11 deletions libp2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ pub use libp2p_core as core;
#[doc(inline)]
pub use libp2p_dcutr as dcutr;
#[cfg(feature = "deflate")]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[cfg(not(target_arch = "wasm32"))]
#[doc(inline)]
pub use libp2p_deflate as deflate;
#[cfg(feature = "dns")]
#[cfg_attr(docsrs, doc(cfg(feature = "dns")))]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[cfg(not(target_arch = "wasm32"))]
#[doc(inline)]
pub use libp2p_dns as dns;
#[cfg(feature = "floodsub")]
Expand All @@ -71,7 +71,7 @@ pub use libp2p_identify as identify;
#[doc(inline)]
pub use libp2p_kad as kad;
#[cfg(feature = "mdns")]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg_attr(docsrs, doc(cfg(feature = "mdns")))]
#[doc(inline)]
pub use libp2p_mdns as mdns;
Expand All @@ -94,7 +94,7 @@ pub use libp2p_plaintext as plaintext;
#[doc(inline)]
pub use libp2p_pnet as pnet;
#[cfg(feature = "quic")]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[cfg(not(target_arch = "wasm32"))]
#[doc(inline)]
pub use libp2p_quic as quic;
#[cfg(feature = "relay")]
Expand All @@ -109,30 +109,30 @@ pub use libp2p_request_response as request_response;
#[doc(inline)]
pub use libp2p_swarm as swarm;
#[cfg(feature = "tcp")]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg_attr(docsrs, doc(cfg(feature = "tcp")))]
#[doc(inline)]
pub use libp2p_tcp as tcp;
#[cfg(feature = "tls")]
#[cfg_attr(docsrs, doc(cfg(feature = "tls")))]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[cfg(not(target_arch = "wasm32"))]
#[doc(inline)]
pub use libp2p_tls as tls;
#[cfg(feature = "uds")]
#[cfg_attr(docsrs, doc(cfg(feature = "uds")))]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[cfg(not(target_arch = "wasm32"))]
#[doc(inline)]
pub use libp2p_uds as uds;
#[cfg(feature = "wasm-ext")]
#[doc(inline)]
pub use libp2p_wasm_ext as wasm_ext;
#[cfg(feature = "webrtc")]
#[cfg_attr(docsrs, doc(cfg(feature = "webrtc")))]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[cfg(not(target_arch = "wasm32"))]
#[doc(inline)]
pub use libp2p_webrtc as webrtc;
#[cfg(feature = "websocket")]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[cfg(not(target_arch = "wasm32"))]
#[doc(inline)]
pub use libp2p_websocket as websocket;
#[cfg(feature = "yamux")]
Expand Down Expand Up @@ -168,7 +168,7 @@ pub use self::transport_ext::TransportExt;
/// > **Note**: This `Transport` is not suitable for production usage, as its implementation
/// > reserves the right to support additional protocols or remove deprecated protocols.
#[cfg(all(
not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")),
not(target_arch = "wasm32"),
any(
all(feature = "tcp-async-io", feature = "dns-async-std"),
all(feature = "tcp", feature = "dns", feature = "async-std")
Expand Down Expand Up @@ -228,7 +228,7 @@ pub async fn development_transport(
/// > **Note**: This `Transport` is not suitable for production usage, as its implementation
/// > reserves the right to support additional protocols or remove deprecated protocols.
#[cfg(all(
not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")),
not(target_arch = "wasm32"),
any(
all(feature = "tcp-tokio", feature = "dns-tokio"),
all(feature = "tcp", feature = "dns", feature = "tokio")
Expand Down

0 comments on commit c06731b

Please sign in to comment.