Skip to content

Commit e6193de

Browse files
committed
Rename wasi -> component as it better refelcts
Signed-off-by: James Sturtevant <jstur@microsoft.com>
1 parent a6ffa36 commit e6193de

10 files changed

Lines changed: 64 additions & 60 deletions

File tree

.github/workflows/dep_rust.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ jobs:
7777
name: guest-modules
7878
path: ./x64/${{ matrix.config }}
7979

80-
- name: Build Rust Wasi examples
81-
run: just build-rust-wasi-examples ${{ matrix.config }}
80+
- name: Build Rust component model examples
81+
run: just build-rust-component-examples ${{ matrix.config }}
8282

8383
- name: Fmt
8484
run: just fmt-check
@@ -127,8 +127,8 @@ jobs:
127127
# required for gh cli when downloading
128128
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129129

130-
- name: Test Wasi Examples
131-
run: just examples-wasi ${{ matrix.config }} ${{ matrix.hypervisor == 'mshv3' && 'mshv3' || ''}}
130+
- name: Test Component Model Examples
131+
run: just examples-components ${{ matrix.config }} ${{ matrix.hypervisor == 'mshv3' && 'mshv3' || ''}}
132132
working-directory: ./src/hyperlight_wasm
133133

134134
### Benchmarks ###

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,4 +478,4 @@ target/
478478

479479
# MSVC Windows builds of rustc generate these, which store debugging information
480480
*.pdb
481-
src/wasi_samples/wit/component-world.wasm
481+
src/component_sample/**/*.wasm

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
members = [ "src/hyperlight_wasm", "src/examples_common", "src/hyperlight_wasm_aot" ]
3-
exclude = [ "src/wasm_runtime", "src/rust_wasm_samples", "src/hyperlight_wasm_macro", "src/wasi_samples" ]
3+
exclude = [ "src/wasm_runtime", "src/rust_wasm_samples", "src/hyperlight_wasm_macro", "src/component_sample" ]
44
resolver = "2"
55

66
[workspace.dependencies]

Justfile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ default-tag:= "latest"
33
build-wasm-examples-command := if os() == "windows" { "./src/hyperlight_wasm/scripts/build-wasm-examples.bat" } else { "./src/hyperlight_wasm/scripts/build-wasm-examples.sh" }
44
mkdir-arg := if os() == "windows" { "-Force" } else { "-p" }
55
latest-release:= if os() == "windows" {"$(git tag -l --sort=v:refname | select -last 2 | select -first 1)"} else {`git tag -l --sort=v:refname | tail -n 2 | head -n 1`}
6-
wit-world := if os() == "windows" { "$env:WIT_WORLD=\"" + justfile_directory() + "\\src\\wasi_samples\\wit\\component-world.wasm" + "\";" } else { "WIT_WORLD=" + justfile_directory() + "/src/wasi_samples/wit/component-world.wasm" }
6+
wit-world := if os() == "windows" { "$env:WIT_WORLD=\"" + justfile_directory() + "\\src\\component_sample\\wit\\component-world.wasm" + "\";" } else { "WIT_WORLD=" + justfile_directory() + "/src/component_sample/wit/component-world.wasm" }
77

88
set windows-shell := ["pwsh.exe", "-NoLogo", "-Command"]
99

10-
build-all target=default-target: (build target) (build-wasm-examples target) (build-rust-wasm-examples target) (build-wasm-runtime target) (build-rust-wasi-examples target)
10+
build-all target=default-target: (build target) (build-wasm-examples target) (build-rust-wasm-examples target) (build-wasm-runtime target) (build-rust-component-examples target)
1111

1212
build target=default-target features="": (build-wasm-runtime target) (fmt-check)
1313
cargo build {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--no-default-features -F " + features } }} --verbose --profile={{ if target == "debug" {"dev"} else { target } }}
@@ -32,39 +32,39 @@ build-rust-wasm-examples target=default-target: (mkdir-redist target)
3232
cargo run -p hyperlight-wasm-aot compile ./src/rust_wasm_samples/target/wasm32-unknown-unknown/{{ target }}/rust_wasm_samples.wasm ./x64/{{ target }}/rust_wasm_samples.aot
3333
cp ./x64/{{ target }}/rust_wasm_samples.aot ./x64/{{ target }}/rust_wasm_samples.wasm
3434

35-
build-rust-wasi-examples target=default-target:
35+
build-rust-component-examples target=default-target:
3636
cargo install --locked wasm-tools
3737
cargo install cargo-component --locked
38-
wasm-tools component wit ./src/wasi_samples/wit/example.wit -w -o ./src/wasi_samples/wit/component-world.wasm
38+
wasm-tools component wit ./src/component_sample/wit/example.wit -w -o ./src/component_sample/wit/component-world.wasm
3939
# use cargo component so we don't get all the wasi imports https://github.com/bytecodealliance/cargo-component?tab=readme-ov-file#relationship-with-wasm32-wasip2
4040
# we also explicitly target wasm32-unknown-unknown since cargo component might try to pull in wasi imports https://github.com/bytecodealliance/cargo-component/issues/290
4141
rustup target add wasm32-unknown-unknown
42-
cd ./src/wasi_samples && cargo component build --target wasm32-unknown-unknown --profile={{ if target == "debug" {"dev"} else { target } }}
43-
cargo run -p hyperlight-wasm-aot compile --component ./src/wasi_samples/target/wasm32-unknown-unknown/{{ target }}/wasi_samples.wasm ./x64/{{ target }}/wasi_samples.aot
44-
cp ./x64/{{ target }}/wasi_samples.aot ./x64/{{ target }}/wasi_samples.wasm
42+
cd ./src/component_sample && cargo component build --target wasm32-unknown-unknown --profile={{ if target == "debug" {"dev"} else { target } }}
43+
cargo run -p hyperlight-wasm-aot compile --component ./src/component_sample/target/wasm32-unknown-unknown/{{ target }}/component_sample.wasm ./x64/{{ target }}/component_sample.aot
44+
cp ./x64/{{ target }}/component_sample.aot ./x64/{{ target }}/component_sample.wasm
4545

4646
check target=default-target:
4747
cargo check --profile={{ if target == "debug" {"dev"} else { target } }}
4848
cd src/rust_wasm_samples && cargo check --profile={{ if target == "debug" {"dev"} else { target } }}
49-
cd src/wasi_samples && cargo check --profile={{ if target == "debug" {"dev"} else { target } }}
49+
cd src/component_sample && cargo check --profile={{ if target == "debug" {"dev"} else { target } }}
5050
cd src/wasm_runtime && cargo check --profile={{ if target == "debug" {"dev"} else { target } }}
5151

5252
fmt-check:
5353
rustup toolchain install nightly -c rustfmt && cargo +nightly fmt -v --all -- --check
5454
cd src/rust_wasm_samples && rustup toolchain install nightly -c rustfmt && cargo +nightly fmt -v --all -- --check
55-
cd src/wasi_samples && rustup toolchain install nightly -c rustfmt && cargo +nightly fmt -v --all -- --check
55+
cd src/component_sample && rustup toolchain install nightly -c rustfmt && cargo +nightly fmt -v --all -- --check
5656
cd src/wasm_runtime && rustup toolchain install nightly -c rustfmt && cargo +nightly fmt -v --all -- --check
5757
fmt:
5858
rustup toolchain install nightly -c rustfmt
5959
cargo +nightly fmt --all
6060
cd src/rust_wasm_samples && cargo +nightly fmt -v --all
61-
cd src/wasi_samples && cargo +nightly fmt -v --all
61+
cd src/component_sample && cargo +nightly fmt -v --all
6262
cd src/wasm_runtime && cargo +nightly fmt -v --all
6363

6464
clippy target=default-target: (check target)
6565
cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
6666
cd src/rust_wasm_samples && cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
67-
cd src/wasi_samples && cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
67+
cd src/component_sample && cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
6868
cd src/wasm_runtime && cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
6969

7070
# TESTING
@@ -88,8 +88,8 @@ examples-ci target=default-target features="": (build-rust-wasm-examples target)
8888
cargo run {{ if features =="" {''} else {"--no-default-features -F function_call_metrics," + features } }} --profile={{ if target == "debug" {"dev"} else { target } }} --example metrics
8989
cargo run {{ if features =="" {"--no-default-features --features kvm,mshv2"} else {"--no-default-features -F function_call_metrics," + features } }} --profile={{ if target == "debug" {"dev"} else { target } }} --example metrics
9090

91-
examples-wasi target=default-target features="": (build-rust-wasi-examples target)
92-
{{ wit-world }} cargo run {{ if features =="" {''} else {"--no-default-features -F " + features } }} --profile={{ if target == "debug" {"dev"} else { target } }} --example wasi_examples
91+
examples-components target=default-target features="": (build-rust-component-examples target)
92+
{{ wit-world }} cargo run {{ if features =="" {''} else {"--no-default-features -F " + features } }} --profile={{ if target == "debug" {"dev"} else { target } }} --example component_example
9393

9494
# warning, compares to and then OVERWRITES the given baseline
9595
bench-ci baseline target=default-target features="":
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "wasi_samples"
2+
name = "component_sample"
33
version = "0.1.0"
44
edition = "2024"
55

@@ -10,7 +10,7 @@ wit-bindgen-rt = { version = "0.41.0", features = ["bitflags"] }
1010
crate-type = ["cdylib"]
1111

1212
[package.metadata.component]
13-
package = "wasi-sample:example"
13+
package = "component-sample:example"
1414

1515
[package.metadata.component.target]
1616
path = "wit/example.wit"
Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// * runtime_path: "wit_bindgen_rt"
44
#[rustfmt::skip]
55
#[allow(dead_code, clippy::all)]
6-
pub mod wasi_sample {
6+
pub mod component_sample {
77
pub mod example {
88
#[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)]
99
pub mod host {
@@ -18,7 +18,7 @@ pub mod wasi_sample {
1818
let ptr0 = vec0.as_ptr().cast::<u8>();
1919
let len0 = vec0.len();
2020
#[cfg(target_arch = "wasm32")]
21-
#[link(wasm_import_module = "wasi-sample:example/host")]
21+
#[link(wasm_import_module = "component-sample:example/host")]
2222
unsafe extern "C" {
2323
#[link_name = "print"]
2424
fn wit_import1(_: *mut u8, _: usize);
@@ -49,7 +49,7 @@ pub mod wasi_sample {
4949
let len0 = vec0.len();
5050
let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>();
5151
#[cfg(target_arch = "wasm32")]
52-
#[link(wasm_import_module = "wasi-sample:example/host")]
52+
#[link(wasm_import_module = "component-sample:example/host")]
5353
unsafe extern "C" {
5454
#[link_name = "host-function"]
5555
fn wit_import2(_: *mut u8, _: usize, _: *mut u8);
@@ -75,7 +75,7 @@ pub mod wasi_sample {
7575
#[rustfmt::skip]
7676
#[allow(dead_code, clippy::all)]
7777
pub mod exports {
78-
pub mod wasi_sample {
78+
pub mod component_sample {
7979
pub mod example {
8080
#[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)]
8181
pub mod adder {
@@ -130,27 +130,29 @@ pub mod exports {
130130
fn do_something(number: u32) -> ();
131131
}
132132
#[doc(hidden)]
133-
macro_rules! __export_wasi_sample_example_adder_cabi {
133+
macro_rules! __export_component_sample_example_adder_cabi {
134134
($ty:ident with_types_in $($path_to_types:tt)*) => {
135135
const _ : () = { #[unsafe (export_name =
136-
"wasi-sample:example/adder#add")] unsafe extern "C" fn
136+
"component-sample:example/adder#add")] unsafe extern "C" fn
137137
export_add(arg0 : i32, arg1 : i32,) -> i32 { unsafe {
138138
$($path_to_types)*:: _export_add_cabi::<$ty > (arg0, arg1) } }
139-
#[unsafe (export_name = "wasi-sample:example/adder#call-host")]
140-
unsafe extern "C" fn export_call_host(arg0 : * mut u8, arg1 :
141-
usize,) -> * mut u8 { unsafe { $($path_to_types)*::
142-
_export_call_host_cabi::<$ty > (arg0, arg1) } } #[unsafe
143-
(export_name = "cabi_post_wasi-sample:example/adder#call-host")]
144-
unsafe extern "C" fn _post_return_call_host(arg0 : * mut u8,) {
145-
unsafe { $($path_to_types)*:: __post_return_call_host::<$ty >
146-
(arg0) } } #[unsafe (export_name =
147-
"wasi-sample:example/adder#do-something")] unsafe extern "C" fn
148-
export_do_something(arg0 : i32,) { unsafe { $($path_to_types)*::
149-
_export_do_something_cabi::<$ty > (arg0) } } };
139+
#[unsafe (export_name =
140+
"component-sample:example/adder#call-host")] unsafe extern "C" fn
141+
export_call_host(arg0 : * mut u8, arg1 : usize,) -> * mut u8 {
142+
unsafe { $($path_to_types)*:: _export_call_host_cabi::<$ty >
143+
(arg0, arg1) } } #[unsafe (export_name =
144+
"cabi_post_component-sample:example/adder#call-host")] unsafe
145+
extern "C" fn _post_return_call_host(arg0 : * mut u8,) { unsafe {
146+
$($path_to_types)*:: __post_return_call_host::<$ty > (arg0) } }
147+
#[unsafe (export_name =
148+
"component-sample:example/adder#do-something")] unsafe extern "C"
149+
fn export_do_something(arg0 : i32,) { unsafe {
150+
$($path_to_types)*:: _export_do_something_cabi::<$ty > (arg0) } }
151+
};
150152
};
151153
}
152154
#[doc(hidden)]
153-
pub(crate) use __export_wasi_sample_example_adder_cabi;
155+
pub(crate) use __export_component_sample_example_adder_cabi;
154156
#[cfg_attr(target_pointer_width = "64", repr(align(8)))]
155157
#[cfg_attr(target_pointer_width = "32", repr(align(4)))]
156158
struct _RetArea(
@@ -275,27 +277,28 @@ macro_rules! __export_example_impl {
275277
};
276278
($ty:ident with_types_in $($path_to_types_root:tt)*) => {
277279
$($path_to_types_root)*::
278-
exports::wasi_sample::example::adder::__export_wasi_sample_example_adder_cabi!($ty
279-
with_types_in $($path_to_types_root)*:: exports::wasi_sample::example::adder);
280+
exports::component_sample::example::adder::__export_component_sample_example_adder_cabi!($ty
281+
with_types_in $($path_to_types_root)*::
282+
exports::component_sample::example::adder);
280283
};
281284
}
282285
#[doc(inline)]
283286
pub(crate) use __export_example_impl as export;
284287
#[cfg(target_arch = "wasm32")]
285288
#[unsafe(
286-
link_section = "component-type:wit-bindgen:0.41.0:wasi-sample:example:example:encoded world"
289+
link_section = "component-type:wit-bindgen:0.41.0:component-sample:example:example:encoded world"
287290
)]
288291
#[doc(hidden)]
289292
#[allow(clippy::octal_escapes)]
290-
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 365] = *b"\
291-
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xef\x01\x01A\x02\x01\
293+
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 380] = *b"\
294+
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xfe\x01\x01A\x02\x01\
292295
A\x04\x01B\x04\x01@\x01\x07messages\x01\0\x04\0\x05print\x01\0\x01@\x01\x05input\
293-
s\0s\x04\0\x0dhost-function\x01\x01\x03\0\x18wasi-sample:example/host\x05\0\x01B\
294-
\x06\x01@\x02\x04lefty\x05righty\0y\x04\0\x03add\x01\0\x01@\x01\x05inputs\0s\x04\
295-
\0\x09call-host\x01\x01\x01@\x01\x06numbery\x01\0\x04\0\x0cdo-something\x01\x02\x04\
296-
\0\x19wasi-sample:example/adder\x05\x01\x04\0\x1bwasi-sample:example/example\x04\
297-
\0\x0b\x0d\x01\0\x07example\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dw\
298-
it-component\x070.227.1\x10wit-bindgen-rust\x060.41.0";
296+
s\0s\x04\0\x0dhost-function\x01\x01\x03\0\x1dcomponent-sample:example/host\x05\0\
297+
\x01B\x06\x01@\x02\x04lefty\x05righty\0y\x04\0\x03add\x01\0\x01@\x01\x05inputs\0\
298+
s\x04\0\x09call-host\x01\x01\x01@\x01\x06numbery\x01\0\x04\0\x0cdo-something\x01\
299+
\x02\x04\0\x1ecomponent-sample:example/adder\x05\x01\x04\0\x20component-sample:e\
300+
xample/example\x04\0\x0b\x0d\x01\0\x07example\x03\0\0\0G\x09producers\x01\x0cpro\
301+
cessed-by\x02\x0dwit-component\x070.227.1\x10wit-bindgen-rust\x060.41.0";
299302
#[inline(never)]
300303
#[doc(hidden)]
301304
pub fn __link_custom_section_describing_imports() {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#[rustfmt::skip]
33
mod bindings;
44

5-
use bindings::exports::wasi_sample::example::adder::Guest;
6-
use bindings::wasi_sample::example::host::{host_function, print};
5+
use bindings::component_sample::example::host::{host_function, print};
6+
use bindings::exports::component_sample::example::adder::Guest;
77

88
struct Component {}
99

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wasi-sample:example;
1+
package component-sample:example;
22

33
world example {
44
import host;

src/hyperlight_wasm/examples/wasi_examples/main.rs renamed to src/hyperlight_wasm/examples/component_example/main.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#![allow(renamed_and_removed_lints)]
2+
#![allow(unknown_lints)]
23
#![allow(unused_unit)]
34

4-
use bindings::wasi_sample::example::Adder;
5+
use bindings::component_sample::example::Adder;
56
use examples_common::get_wasm_module_path;
67

78
extern crate alloc;
89
mod bindings {
9-
hyperlight_component_macro::host_bindgen!("../wasi_samples/wit/component-world.wasm");
10+
hyperlight_component_macro::host_bindgen!("../component_sample/wit/component-world.wasm");
1011
}
1112

1213
pub struct State {}
@@ -22,7 +23,7 @@ impl Default for State {
2223
}
2324
}
2425

25-
impl bindings::wasi_sample::example::Host for State {
26+
impl bindings::component_sample::example::Host for State {
2627
fn r#print(&mut self, message: alloc::string::String) {
2728
assert_eq!("42", message);
2829
println!("Logged from component: {message}");
@@ -34,7 +35,7 @@ impl bindings::wasi_sample::example::Host for State {
3435
}
3536

3637
#[allow(refining_impl_trait)]
37-
impl bindings::wasi_sample::example::ExampleImports for State {
38+
impl bindings::component_sample::example::ExampleImports for State {
3839
type Host = State;
3940

4041
fn r#host(&mut self) -> &mut Self {
@@ -54,12 +55,12 @@ fn main() {
5455

5556
let sb = sb.load_runtime().unwrap();
5657

57-
let mod_path = get_wasm_module_path("wasi_samples.wasm").unwrap();
58+
let mod_path = get_wasm_module_path("component_sample.wasm").unwrap();
5859
let sb = sb.load_module(mod_path).unwrap();
5960

6061
let mut wrapped = bindings::ExampleSandbox { sb, rt };
6162

62-
let instance = bindings::wasi_sample::example::ExampleExports::adder(&mut wrapped);
63+
let instance = bindings::component_sample::example::ExampleExports::adder(&mut wrapped);
6364
let result = instance.add(1, 2);
6465
assert_eq!(3, result);
6566
println!("Add result is {result}");

0 commit comments

Comments
 (0)