From df3e332b0315de45e40114f3ed8b05d859ee0cd9 Mon Sep 17 00:00:00 2001 From: EthanYuan Date: Mon, 28 Aug 2023 18:16:49 +0800 Subject: [PATCH] Implemented a workaround to bypass the [issue](https://github.com/rust-lang/cargo/issues/8170). --- util/hash/Cargo.toml | 15 +++++++++------ util/hash/src/lib.rs | 3 +++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/util/hash/Cargo.toml b/util/hash/Cargo.toml index 53d79c81d4e..c14d15c903e 100644 --- a/util/hash/Cargo.toml +++ b/util/hash/Cargo.toml @@ -9,11 +9,14 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [features] -default = [] -ckb-contract = [] # This feature is used for CKB contract development +default = ["blake2b"] +ckb-contract = ["blake2b-ref"] # This feature is used for CKB contract development -[target.'cfg(not(any(target_arch = "wasm32", features = "ckb-contract")))'.dependencies] -blake2b = { package = "blake2b-rs", version = "0.2" } +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +blake2b = { package = "blake2b-rs", version = "0.2", optional = true } -[target.'cfg(any(target_arch = "wasm32", features = "ckb-contract"))'.dependencies] -blake2b = { package = "blake2b-ref", version = "0.2.0" } +[target.'cfg(target_arch = "wasm32")'.dependencies] +blake2b = { package = "blake2b-ref", version = "0.2.0", optional = true } + +[dependencies] +blake2b-ref = { version = "0.2.0", optional = true } \ No newline at end of file diff --git a/util/hash/src/lib.rs b/util/hash/src/lib.rs index 5debb844e18..651e3168bb4 100644 --- a/util/hash/src/lib.rs +++ b/util/hash/src/lib.rs @@ -9,7 +9,10 @@ #![no_std] +#[cfg(feature = "default")] pub use blake2b::{Blake2b, Blake2bBuilder}; +#[cfg(feature = "ckb-contract")] +pub use blake2b_ref::{Blake2b, Blake2bBuilder}; #[doc(hidden)] pub const BLAKE2B_KEY: &[u8] = &[];