Skip to content

Commit f604f4d

Browse files
committed
add ability to run multiiple wasi versions
Signed-off-by: karthik2804 <[email protected]>
1 parent 63ba57a commit f604f4d

File tree

5 files changed

+9
-20
lines changed

5 files changed

+9
-20
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ spin-factor-wasi = { git = "https://github.com/spinframework/spin", tag = "v3.2.
2424
spin-runtime-factors = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" }
2525
tokio = { version = "1.38", features = ["rt", "macros"] }
2626
tracing = { version = "0.1", features = ["log"] }
27+
wasmtime-wasi = "29.0.1"
2728

2829
[target.'cfg(target_os = "linux")'.dependencies]
2930
# This needs to be an explicit dependency to enable

examples/async/spin.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ description = ""
1010
component = "job"
1111

1212
[component.job]
13-
source = "target/wasm32-wasi/release/job.wasm"
13+
source = "target/wasm32-wasip1/release/job.wasm"
1414
allowed_outbound_hosts = ["https://myip.fermyon.app/"]
15-
build = ["cargo component build --target wasm32-wasi --release"]
15+
build = ["cargo component build --target wasm32-wasip1 --release"]

examples/hello-world/spin.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ version = "0.1.0"
1010
component = "hello-world"
1111

1212
[component.hello-world]
13-
source = "target/wasm32-wasi/release/hello_world.wasm"
14-
build = ["cargo component build --target wasm32-wasi --release"]
15-
13+
source = "target/wasm32-wasip1/release/hello_world.wasm"
14+
build = ["cargo component build --target wasm32-wasip1 --release"]

src/lib.rs

+3-15
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,9 @@ impl CommandTrigger {
9292
}
9393

9494
let (instance, mut store) = instance_builder.instantiate(()).await?;
95-
96-
let func = {
97-
let instance_export = instance
98-
.get_export(&mut store, None, "wasi:cli/[email protected]")
99-
.context("failed to find the wasi:cli/[email protected] instance in component")?;
100-
101-
let func_export = instance
102-
.get_export(&mut store, Some(&instance_export), "run")
103-
.context("failed to find the \"run\" function in wasi:cli/[email protected] instance")?;
104-
105-
instance
106-
.get_typed_func::<(), (Result<(), ()>,)>(&mut store, func_export)
107-
.context("failed to get typed \"run\" function")?
108-
};
109-
let _ = func.call_async(&mut store, ()).await?;
95+
let func = wasmtime_wasi::bindings::Command::new(&mut store, &instance)?;
96+
let func = func.wasi_cli_run();
97+
let _ = func.call_run(store).await?;
11098

11199
Ok(())
112100
}

0 commit comments

Comments
 (0)