Skip to content

Commit

Permalink
Update wit-bindgen and wasm-tools. (#266)
Browse files Browse the repository at this point in the history
* Update wit-bindgen and wasm-tools.

The two code changes are:
 - The float32->f32 renaming.
 - wit-bindgen-rt now provides a re-export of the bitflags crate,
   so that users don't need to separately depend on bitflags.

* Update wit-bindgen-rt in the example.

* Update Wasmtime, actions/checkout, mozilla-actions/sccache-action in CI.
  • Loading branch information
sunfishcode committed Mar 28, 2024
1 parent 658dc2e commit 9ef9317
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 52 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Configure sccache
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3
uses: mozilla-actions/sccache-action@v0.0.4
- name: Install Rust
run: |
rustup set profile minimal
Expand All @@ -37,15 +37,15 @@ jobs:
uses: bytecodealliance/actions/wasmtime/setup@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
version: "v18.0.1"
version: "v19.0.0"
- name: Run all tests
run: cargo test --all

example:
name: Build example component
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable && rustup target add wasm32-wasi && rustup target add wasm32-unknown-unknown
- name: Install cargo-component (debug)
Expand All @@ -57,7 +57,7 @@ jobs:
name: Install cargo-component
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- name: Install cargo-component
Expand All @@ -67,7 +67,7 @@ jobs:
name: Format source code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
- name: Run `cargo fmt`
Expand Down
60 changes: 30 additions & 30 deletions Cargo.lock

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

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
indexmap = "2.2.5"
url = { version = "2.5.0", features = ["serde"] }
wit-parser = "0.201.0"
wit-component = "0.201.0"
wasm-metadata = "0.201.0"
wit-parser = "0.202.0"
wit-component = "0.202.0"
wasm-metadata = "0.202.0"
parse_arg = "0.1.4"
cargo_metadata = "0.18.1"
cargo-config2 = "0.1.19"
Expand All @@ -102,14 +102,14 @@ futures = "0.3.30"
bytes = "1.5.0"
which = "6.0.0"
secrecy = "0.8.0"
wit-bindgen-rust = "0.21.0"
wit-bindgen-core = "0.21.0"
wit-bindgen-rust = "0.23.0"
wit-bindgen-core = "0.23.0"
tempfile = "3.10.1"
assert_cmd = "2.0.14"
predicates = "3.1.0"
wasmparser = "0.201.0"
wat = "1.201.0"
wasmprinter = "0.201.0"
wasmparser = "0.202.0"
wat = "1.202.0"
wasmprinter = "0.202.0"

[profile.release]
panic = "abort"
Expand Down
3 changes: 1 addition & 2 deletions example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
bitflags = "2.4.2"
wit-bindgen-rt = "0.20.0"
wit-bindgen-rt = { version = "0.23.0", features = ["bitflags"] }

[package.metadata.component]
package = "example:component"
Expand Down
2 changes: 1 addition & 1 deletion src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl<'a> BindingsGenerator<'a> {
additional_derive_attributes: settings.derives.clone(),
std_feature: settings.std_feature,
runtime_path: Some("wit_bindgen_rt".to_string()),
bitflags_path: Some("bitflags".to_string()),
bitflags_path: Some("wit_bindgen_rt::bitflags".to_string()),
..Default::default()
};

Expand Down
6 changes: 3 additions & 3 deletions src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use toml_edit::{table, value, Document, Item, Table, Value};
use url::Url;

const WIT_BINDGEN_RT_CRATE: &str = "wit-bindgen-rt";
const BITFLAGS_CRATE: &str = "bitflags";

fn escape_wit(s: &str) -> Cow<str> {
match s {
Expand Down Expand Up @@ -304,13 +303,14 @@ impl NewCommand {
cargo_add_command.arg("add");
cargo_add_command.arg("--quiet");
cargo_add_command.arg(WIT_BINDGEN_RT_CRATE);
cargo_add_command.arg(BITFLAGS_CRATE);
cargo_add_command.arg("--features");
cargo_add_command.arg("bitflags");
cargo_add_command.current_dir(out_dir);
let status = cargo_add_command
.status()
.context("failed to execute `cargo add` command")?;
if !status.success() {
bail!("`cargo add {WIT_BINDGEN_RT_CRATE} {BITFLAGS_CRATE}` command exited with non-zero status");
bail!("`cargo add {WIT_BINDGEN_RT_CRATE} --features bitflags` command exited with non-zero status");
}

config.terminal().status(
Expand Down
4 changes: 2 additions & 2 deletions src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ impl<'a> UnimplementedFunction<'a> {
Type::S16 => source.push_str("i16"),
Type::S32 => source.push_str("i32"),
Type::S64 => source.push_str("i64"),
Type::Float32 => source.push_str("f32"),
Type::Float64 => source.push_str("f64"),
Type::F32 => source.push_str("f32"),
Type::F64 => source.push_str("f64"),
Type::Char => source.push_str("char"),
Type::String => source.push_str("String"),
Type::Id(id) => self.print_type_id(in_world, *id, trie, source)?,
Expand Down

0 comments on commit 9ef9317

Please sign in to comment.