Skip to content
Open
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
51 changes: 51 additions & 0 deletions .github/regenerate-wasi-bindings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Helper script executed from CI to execute `wit-bindgen` and regenerate the
# bindings for the WASIp2 and WASIp3 targets.

set -ex

# Disable some features required for compat with really old toolchains/WASI
# versions that aren't required here.
args="--disable-custom-section-link-helpers"
args="$args --disable-run-ctors-once-workaround"

# Make the generated code a bit easier to read
args="$args --format"

# Use `feature = "std"` if needed, mostly intended for future compat if ever
# since this isn't needed currently.
args="$args --std-feature"

# Fail to compile if a runtime-path is actually needed, and it shouldn't be
# given the current generated bindings.
args="$args --runtime-path nonexisten"

# The custom section generated by wit-bindgen needs a globally unique version in
# the entire crate graph, so "salt" it with the `rand` crate's version which
# should be sufficient enough for now.
rand_version=$(cat Cargo.toml | grep '^version' | sed 's/version = "\(.*\)"/\1/')
args="$args --type-section-suffix rust-rand-${rand_version}"

# Skip generated bindings for functions that this crate doesn't use.
args="$args --skip=get-random-bytes"
args="$args --skip=get-insecure-random-bytes"
args="$args --skip=get-insecure-random-u64"
args="$args --skip=get-insecure-seed"

# WASIp2 bindings
wasip2=0.2.10
curl -LO https://github.com/WebAssembly/WASI/releases/download/v$wasip2/wasi-wit-$wasip2.tar.gz
tar xf wasi-wit-$wasip2.tar.gz
wit-bindgen rust $args ./wasi-wit-$wasip2/random \
--world imports \
--out-dir src/backends/wasi_p2_3/p2

# WASIp3 bindings
#
# Note that the folder structure is a bit different for WASIp2 for now, but it's
# expected to converge on the same structure as WASIp2 above eventually.
wasip3=0.3.0-rc-2026-01-06
curl -LO https://github.com/WebAssembly/WASI/archive/refs/tags/v$wasip3.tar.gz
tar xf v$wasip3.tar.gz
wit-bindgen rust $args ./WASI-$wasip3/proposals/random/wit-0.3.0-draft \
--world imports \
--out-dir src/backends/wasi_p2_3/p3
23 changes: 17 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,9 @@ jobs:
wget -O - $URL | tar -xJ --strip-components=1 -C ~/.cargo/bin
wasmtime --version
- uses: Swatinem/rust-cache@v2
# TODO(MSRV-1.87): Remove this step.
- name: Generate MSRV-compatible Cargo.lock
env:
CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS: "fallback"
run: cargo update -p wasip2
- run: cargo test --target wasm32-wasip2

# TODO: enable after pre-built std will be provided by Rust
# TODO: enable after pre-built std will be provided by Rust
# wasi_p3:
# name: WASIp3
# runs-on: ubuntu-24.04
Expand All @@ -416,3 +411,19 @@ jobs:
# wasmtime --version
# - uses: Swatinem/rust-cache@v2
# - run: cargo test --target wasm32-wasip3

wasi_bindings:
name: WASI bindings up-to-date
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Install wit-bindgen
run: |
VERSION=0.53.1
URL=https://github.com/bytecodealliance/wit-bindgen/releases/download/v${VERSION}/wit-bindgen-${VERSION}-x86_64-linux.tar.gz
wget -O - $URL | tar -xz --strip-components=1 -C ~/.cargo/bin
wit-bindgen --version
- name: Generate bindings
run: sh .github/regenerate-wasi-bindings.sh
- name: Ensure generated files up-to-date
run: git diff --exit-code
3 changes: 2 additions & 1 deletion .typos.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[files]
extend-exclude = [
".git/"
".git/",
"src/backends/wasi_p2_3",
]

[default.extend-words]
Expand Down
Loading