Skip to content

add ability to run multiiple wasi versions #55

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
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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spin-factor-wasi = { git = "https://github.com/spinframework/spin", tag = "v3.2.
spin-runtime-factors = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" }
tokio = { version = "1.38", features = ["rt", "macros"] }
tracing = { version = "0.1", features = ["log"] }
wasmtime-wasi = "29.0.1"

[target.'cfg(target_os = "linux")'.dependencies]
# This needs to be an explicit dependency to enable
Expand Down
4 changes: 2 additions & 2 deletions examples/async/spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ description = ""
component = "job"

[component.job]
source = "target/wasm32-wasi/release/job.wasm"
source = "target/wasm32-wasip1/release/job.wasm"
allowed_outbound_hosts = ["https://myip.fermyon.app/"]
build = ["cargo component build --target wasm32-wasi --release"]
build = ["cargo component build --target wasm32-wasip1 --release"]
5 changes: 2 additions & 3 deletions examples/hello-world/spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ version = "0.1.0"
component = "hello-world"

[component.hello-world]
source = "target/wasm32-wasi/release/hello_world.wasm"
build = ["cargo component build --target wasm32-wasi --release"]

source = "target/wasm32-wasip1/release/hello_world.wasm"
build = ["cargo component build --target wasm32-wasip1 --release"]
18 changes: 3 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,9 @@ impl CommandTrigger {
}

let (instance, mut store) = instance_builder.instantiate(()).await?;

let func = {
let instance_export = instance
.get_export(&mut store, None, "wasi:cli/[email protected]")
.context("failed to find the wasi:cli/[email protected] instance in component")?;

let func_export = instance
.get_export(&mut store, Some(&instance_export), "run")
.context("failed to find the \"run\" function in wasi:cli/[email protected] instance")?;

instance
.get_typed_func::<(), (Result<(), ()>,)>(&mut store, func_export)
.context("failed to get typed \"run\" function")?
};
let _ = func.call_async(&mut store, ()).await?;
let func = wasmtime_wasi::bindings::Command::new(&mut store, &instance)?;
let func = func.wasi_cli_run();
let _ = func.call_run(store).await?;

Ok(())
}
Expand Down
Loading