Skip to content

Commit

Permalink
feat(iroh-base): wasm compatability
Browse files Browse the repository at this point in the history
- check all features build in CI
- reorganize features to pull in what is needed
- add `wasm` feature needed for randomness
  • Loading branch information
dignifiedquire committed May 17, 2024
1 parent eebf6d1 commit 6e99fa3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ jobs:
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG' }}


wasm_build:
name: Build wasm32
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable

- name: Add wasm target
run: rustup target add wasm32-unknown-unknown

- name: wasm32 build (iroh-base)
run: cargo build -p iroh-base --all-features --target wasm32-unknown-unknown

check_semver:
runs-on: ubuntu-latest
env:
Expand Down
3 changes: 2 additions & 1 deletion Cargo.lock

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

11 changes: 7 additions & 4 deletions iroh-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ workspace = true

[dependencies]
anyhow = { version = "1" }
bao-tree = { version = "0.13", features = ["tokio_fsm", "validate"], default-features = false, optional = true }
blake3 = { version = "1.4.5", package = "iroh-blake3", optional = true }
data-encoding = { version = "2.3.3", optional = true }
hex = "0.4.3"
postcard = { version = "1", default-features = false, features = ["alloc", "use-std", "experimental-derive"], optional = true }
Expand All @@ -37,6 +37,8 @@ ttl_cache = { version = "0.5.1", optional = true }
crypto_box = { version = "0.9.1", features = ["serde", "chacha20"], optional = true }
zeroize = { version = "1.5", optional = true }
url = { version = "2.5.0", features = ["serde"], optional = true }
# wasm
getrandom = { version = "0.2", default-features = false, optional = true }

[dev-dependencies]
iroh-test = { path = "../iroh-test" }
Expand All @@ -46,10 +48,11 @@ serde_test = "1.0.176"

[features]
default = ["hash", "base32"]
hash = ["dep:bao-tree", "dep:data-encoding", "dep:postcard", "dep:derive_more"]
base32 = ["dep:data-encoding"]
hash = ["dep:blake3", "dep:data-encoding", "dep:postcard", "dep:derive_more", "base32"]
base32 = ["dep:data-encoding", "dep:postcard"]
redb = ["dep:redb"]
key = ["dep:ed25519-dalek", "dep:once_cell", "dep:rand", "dep:rand_core", "dep:ssh-key", "dep:ttl_cache", "dep:aead", "dep:crypto_box", "dep:zeroize", "dep:url", "dep:derive_more"]
key = ["dep:ed25519-dalek", "dep:once_cell", "dep:rand", "dep:rand_core", "dep:ssh-key", "dep:ttl_cache", "dep:aead", "dep:crypto_box", "dep:zeroize", "dep:url", "dep:derive_more", "dep:getrandom"]
wasm = ["getrandom?/js"]

[package.metadata.docs.rs]
all-features = true
1 change: 0 additions & 1 deletion iroh-base/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use std::str::FromStr;
use std::{borrow::Borrow, fmt};

use bao_tree::blake3;
use postcard::experimental::max_size::MaxSize;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};

Expand Down

0 comments on commit 6e99fa3

Please sign in to comment.