Skip to content

Commit 1aeb2a2

Browse files
dan-dajan-ferdinand
authored andcommitted
chore: add wasm feature flag
makes twenty-first "wasm-friendly" such that it builds when target_arch is wasm32. This enables twenty-first to be used inside a web-browser's web-assembly environment. Tests do not presently build for wasm32 target. Addressing that is more complicated and will be the focus of subsequent commits.
1 parent aedecf9 commit 1aeb2a2

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

twenty-first/.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[target.wasm32-unknown-unknown]
2+
rustflags = ["--cfg", "getrandom_backend=\"wasm_js\""]

twenty-first/Cargo.toml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,21 @@ keywords = ["polynomial", "merkle-tree", "post-quantum", "algebra", "tip5"]
1616
categories = ["cryptography", "mathematics"]
1717

1818
[dev-dependencies]
19-
blake3 = "1.5.5"
2019
bincode = "1.3.3"
21-
criterion = { version = "0.6", features = ["html_reports"] }
22-
proptest = "1.6"
23-
proptest-arbitrary-interop = "0.1"
20+
blake3 = "1.5.5"
2421
test-strategy = "0.4"
2522
trybuild = "1.0"
2623

24+
# dev deps for wasm32 target arch
25+
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
26+
criterion = { version = "0.6.0", default-features = false, features = ["html_reports"] }
27+
28+
# dev deps for everything except wasm32 target arch
29+
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
30+
criterion = { version = "0.6", features = ["html_reports"] }
31+
proptest = { version = "1.6.0", default-features = false, features = ["std"] }
32+
proptest-arbitrary-interop = "0.1"
33+
2734
[dev-dependencies.cargo-husky]
2835
version = "1"
2936
default-features = false
@@ -48,6 +55,14 @@ sha3 = "^0.10.8"
4855
thiserror = "2.0"
4956
zeroize = { version = "1.8.1", features = ["derive"] }
5057

58+
# deps for wasm32 target arch
59+
[target.'cfg(target_arch = "wasm32")'.dependencies]
60+
61+
# convince getrandom to build for wasm target.
62+
# note that there is also a flag in .cargo/config.toml
63+
getrandom = { version = "0.3", features = ["wasm_js"] }
64+
wasm-bindgen = "=0.2.100"
65+
5166
[lints]
5267
workspace = true
5368

0 commit comments

Comments
 (0)