From 8a1aaed7611504698154bcaf5ba9dc9a50c5d81b Mon Sep 17 00:00:00 2001 From: Robert Klotzner Date: Sun, 14 Mar 2021 16:49:26 +0100 Subject: [PATCH] Fix wasm build. --- primitives/Cargo.toml | 5 +++-- primitives/src/v1.rs | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index bb841c4d1b0e..0c887ece5023 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -27,7 +27,9 @@ frame-system = { git = "https://github.com/paritytech/substrate", branch = "mast hex-literal = "0.3.1" parity-util-mem = { version = "0.9.0", default-features = false, optional = true } thiserror = "1.0.23" -zstd = { version = "0.5.0", optional = true } + +[target.'cfg(not(target_os = "unknown"))'.dependencies] +zstd = "0.5.0" [dev-dependencies] sp-serializer = { git = "https://github.com/paritytech/substrate", branch = "master" } @@ -56,5 +58,4 @@ std = [ "polkadot-core-primitives/std", "bitvec/std", "frame-system/std", - "zstd" ] diff --git a/primitives/src/v1.rs b/primitives/src/v1.rs index ede798a68c95..adbf6e9a77b9 100644 --- a/primitives/src/v1.rs +++ b/primitives/src/v1.rs @@ -475,19 +475,19 @@ pub enum CompressedPoVError { #[cfg(feature = "std")] impl CompressedPoV { /// Compress the given [`PoV`] and returns a [`CompressedPoV`]. - #[cfg(feature = "std")] + #[cfg(not(target_os = "unknown"))] pub fn compress(pov: &PoV) -> Result { zstd::encode_all(pov.encode().as_slice(), 3).map_err(|_| CompressedPoVError::Compress).map(Self) } /// Compress the given [`PoV`] and returns a [`CompressedPoV`]. - #[cfg(not(feature = "std"))] + #[cfg(target_os = "unknown")] pub fn compress(_: &PoV) -> Result { Err(CompressedPoVError::NotSupported) } /// Decompress `self` and returns the [`PoV`] on success. - #[cfg(feature = "std")] + #[cfg(not(target_os = "unknown"))] pub fn decompress(&self) -> Result { use std::io::Read; const MAX_POV_BLOCK_SIZE: usize = 32 * 1024 * 1024; @@ -511,13 +511,12 @@ impl CompressedPoV { } /// Decompress `self` and returns the [`PoV`] on success. - #[cfg(not(feature = "std"))] + #[cfg(target_os = "unknown")] pub fn decompress(&self) -> Result { Err(CompressedPoVError::NotSupported) } } -#[cfg(feature = "std")] impl std::fmt::Debug for CompressedPoV { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "CompressedPoV({} bytes)", self.0.len())