Skip to content

feat(iroh-net-report): Support wasm32 building & running #3139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,20 @@ jobs:
- name: wasm32 build (iroh-relay)
run: cargo build --target wasm32-unknown-unknown -p iroh-relay --no-default-features

- name: wasm32 build (iroh-net-report)
run: cargo build --target wasm32-unknown-unknown -p iroh-net-report --no-default-features

# If the Wasm file contains any 'import "env"' declarations, then
# some non-Wasm-compatible code made it into the final code.
- name: Ensure no 'import "env"' in iroh-relay Wasm
run: |
! wasm-tools print --skeleton target/wasm32-unknown-unknown/debug/iroh_relay.wasm | grep 'import "env"'

# If the Wasm file contains any 'import "env"' declarations, then
# some non-Wasm-compatible code made it into the final code.
- name: Ensure no 'import "env"' in iroh-net-report Wasm
run: |
! wasm-tools print --skeleton target/wasm32-unknown-unknown/debug/iroh_net_report.wasm | grep 'import "env"'


check_semver:
Expand Down
17 changes: 17 additions & 0 deletions Cargo.lock

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

25 changes: 18 additions & 7 deletions iroh-net-report/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,49 @@ keywords = ["networking"]
# Sadly this also needs to be updated in .github/workflows/ci.yml
rust-version = "1.81"

[lib]
crate-type = ["lib", "cdylib"] # cdylib is needed for Wasm support

[lints]
workspace = true

[dependencies]
anyhow = "1"
bytes = "1.7"
derive_more = { version = "1.0.0", features = ["display"] }
hickory-resolver = "=0.25.0-alpha.5"
iroh-base = { version = "0.32.0", path = "../iroh-base", default-features = false, features = ["relay"] }
iroh-metrics = { version = "0.31", default-features = false }
iroh-relay = { version = "0.32", path = "../iroh-relay" }
iroh-relay = { version = "0.32", default-features = false, path = "../iroh-relay" }
n0-future = "0.1.2"
netwatch = { version = "0.3" }
portmapper = { version = "0.3", default-features = false }
quinn = { package = "iroh-quinn", version = "0.13.0" }
quinn = { package = "iroh-quinn", version = "0.13.0", default-features = false }
rand = "0.8"
reqwest = { version = "0.12", default-features = false }
reqwest = { version = "0.12", default-features = false, features = ["stream"] }
rustls = { version = "0.23", default-features = false }
surge-ping = "0.8.0"
thiserror = "2"
tokio = { version = "1", default-features = false, features = ["sync", "time", "macros", "rt"] }
tokio-util = { version = "0.7.12", default-features = false }
tracing = "0.1"
url = { version = "2.4" }

# non-wasm-in-browser dependencies
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dependencies]
hickory-resolver = "=0.25.0-alpha.5"
netwatch = { version = "0.3" }
portmapper = { version = "0.3", default-features = false }
surge-ping = "0.8.0"

[dev-dependencies]
futures-lite = "2.3"
iroh-relay = { path = "../iroh-relay", features = ["test-utils", "server"] }
pretty_assertions = "1.4"
quinn = { package = "iroh-quinn", version = "0.13.0" }
testresult = "0.4.0"
tokio = { version = "1", default-features = false, features = ["test-util"] }
tracing-test = "0.2.5"

[build-dependencies]
cfg_aliases = { version = "0.2" }

[features]
default = ["metrics"]
metrics = ["iroh-metrics/metrics", "portmapper/metrics"]
Expand Down
9 changes: 9 additions & 0 deletions iroh-net-report/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use cfg_aliases::cfg_aliases;

fn main() {
// Setup cfg aliases
cfg_aliases! {
// Convenience aliases
wasm_browser: { all(target_family = "wasm", target_os = "unknown") },
}
}
Loading
Loading