Skip to content

Commit

Permalink
Update wit-bindgen 0.17.1 -> 0.25.0 (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Jun 5, 2024
1 parent 6585bdf commit 7a1d14c
Show file tree
Hide file tree
Showing 11 changed files with 399 additions and 301 deletions.
133 changes: 110 additions & 23 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ wasmparser = "0.121.2"

[workspace.dependencies]
anyhow = "1"
wit-bindgen = "0.17.1"
wit-bindgen = "0.25.0"
Binary file modified lib/virtual_adapter.debug.wasm
Binary file not shown.
Binary file modified lib/virtual_adapter.wasm
Binary file not shown.
24 changes: 21 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,30 @@ impl WasiVirt {
Default::default()
};

let component_type_section_id = module
.customs
.iter()
.find_map(|(id, section)| {
let name = section.name();
if name.starts_with("component-type:")
&& section.as_any().is::<walrus::RawCustomSection>()
{
Some(id)
} else {
None
}
})
.context("Unable to find component type section")?;

// decode the component custom section to strip out the unused world exports
// before reencoding.
let mut component_section = module
let mut component_section = *module
.customs
.remove_raw("component-type:virtual-adapter")
.context("Unable to find component section")?;
.delete(component_type_section_id)
.context("Unable to find component section")?
.into_any()
.downcast::<walrus::RawCustomSection>()
.unwrap();

let (mut resolve, pkg_id) = match wit_component::decode(VIRT_WIT_METADATA)? {
DecodedWasm::WitPackage(resolve, pkg_id) => (resolve, pkg_id),
Expand Down
5 changes: 2 additions & 3 deletions tests/components/do-everything/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ extern crate rand;
wit_bindgen::generate!({
path: "../../../wit",
world: "virt-test",
exports: {
world: VirtTestComponent
},
});

struct VirtTestComponent;
Expand All @@ -34,3 +31,5 @@ impl Guest for VirtTestComponent {
unimplemented!();
}
}

export!(VirtTestComponent);
5 changes: 2 additions & 3 deletions tests/components/file-read/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ use std::{fs, io::ErrorKind};
wit_bindgen::generate!({
path: "../../../wit",
world: "virt-test",
exports: {
world: VirtTestComponent
},
});

struct VirtTestComponent;
Expand Down Expand Up @@ -67,3 +64,5 @@ impl Guest for VirtTestComponent {
unimplemented!();
}
}

export!(VirtTestComponent);
5 changes: 2 additions & 3 deletions tests/components/get-env/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ use std::env;
wit_bindgen::generate!({
path: "../../../wit",
world: "virt-test",
exports: {
world: VirtTestComponent
},
});

struct VirtTestComponent;
Expand All @@ -21,3 +18,5 @@ impl Guest for VirtTestComponent {
unimplemented!();
}
}

export!(VirtTestComponent);
5 changes: 2 additions & 3 deletions tests/components/stdio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ use std::env;
wit_bindgen::generate!({
path: "../../../wit",
world: "virt-test",
exports: {
world: VirtTestComponent
},
});

struct VirtTestComponent;
Expand All @@ -21,3 +18,5 @@ impl Guest for VirtTestComponent {
println!("Hello world");
}
}

export!(VirtTestComponent);
Loading

0 comments on commit 7a1d14c

Please sign in to comment.