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 Sep 1, 2023
1 parent d9549ab commit 156a759
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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"
ckb-hash = { path = "../hash", version = "= 0.111.0-rc11" }
molecule = { version = "0.7.5", default-features = false }
ckb-hash = { path = "../hash", version = "= 0.111.0-rc11", default-features = false, optional = true }
ckb-fixed-hash = { path = "../fixed-hash", version = "= 0.111.0-rc11", optional = true }
ckb-error = { path = "../../error", version = "= 0.111.0-rc11", optional = true }
ckb-occupied-capacity = { path = "../occupied-capacity", version = "= 0.111.0-rc11", 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.3", optional = true }

[dependencies]
blake2b-ref = { version = "0.3", 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 156a759

Please sign in to comment.