Skip to content

Commit

Permalink
Implemented a workaround to bypass the [issue](rust-lang/cargo#8170).
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanYuan committed Aug 28, 2023
1 parent 5f0304b commit 355aea1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions util/gen-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ check-data = []
# Enable the `serialized-size` extension for CKB contract development in `no-std` env
serialized-size = ["calc-hash"]
# Enable all in `std` env
std = ["molecule/std", "ckb-hash", "ckb-fixed-hash", "ckb-error", "ckb-occupied-capacity", "numext-fixed-uint"]
std = ["molecule/std", "ckb-hash/default", "ckb-fixed-hash", "ckb-error", "ckb-occupied-capacity", "numext-fixed-uint"]

[dependencies]
cfg-if = "1.0"
molecule = { version = "0.7.5", default-features = false }
ckb-hash = { path = "../hash", version = "= 0.112.0-pre", optional = true }
ckb-hash = { path = "../hash", version = "= 0.112.0-pre", default-features = false, optional = true }
ckb-fixed-hash = { path = "../fixed-hash", version = "= 0.112.0-pre", optional = true }
ckb-error = { path = "../../error", version = "= 0.112.0-pre", optional = true }
ckb-occupied-capacity = { path = "../occupied-capacity", version = "= 0.112.0-pre", optional = true }
Expand Down
15 changes: 9 additions & 6 deletions util/hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
3 changes: 3 additions & 0 deletions util/hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] = &[];
Expand Down

0 comments on commit 355aea1

Please sign in to comment.