@@ -3,10 +3,15 @@ default-tag:= "latest"
33build-wasm-examples-command := if os () == " windows" { " ./src/hyperlight_wasm/scripts/build-wasm-examples.bat" } else { " ./src/hyperlight_wasm/scripts/build-wasm-examples.sh" }
44mkdir-arg := if os () == " windows" { " -Force" } else { " -p" }
55latest-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\\ component_sample\\ wit\\ component-world.wasm" + " \" ;" } else { " WIT_WORLD=" + justfile_directory () + " /src/component_sample/wit/component-world.wasm" }
67
78set windows-shell := [" pwsh.exe" , " -NoLogo" , " -Command" ]
89
9- build-all target = default-target : (build target) (build-wasm-examples target) (build-rust-wasm-examples target) (build-wasm-runtime target)
10+ ensure-tools :
11+ cargo install --locked wasm-tools --version 1.235.0
12+ cargo install cargo-component --locked --version 0.21.1
13+
14+ 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)
1015
1116build target = default-target features = " ": (build-wasm-runtime target) (fmt-check )
1217 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 } }}
@@ -31,23 +36,37 @@ build-rust-wasm-examples target=default-target: (mkdir-redist target)
3136 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
3237 cp ./ x64 / {{ target }} / rust_wasm_samples.aot ./ x64 / {{ target }} / rust_wasm_samples.wasm
3338
39+ build-rust-component-examples target = default-target :
40+ wasm-tools component wit ./ src/ component_sample/ wit/ example.wit -w -o ./ src/ component_sample/ wit/ component-world.wasm
41+ # 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
42+ # 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
43+ rustup target add wasm32 -unknown-unknown
44+ cd ./ src/ component_sample && cargo component build --target wasm32 -unknown-unknown --profile={{ if target == " debug" {" dev" } else { target } }}
45+ cargo run -p hyperlight-wasm-aot compile --component ./ src/ component_sample/ target/ wasm32 -unknown-unknown/ {{ target }} / component_sample.wasm ./ x64 / {{ target }} / component_sample.aot
46+ cp ./ x64 / {{ target }} / component_sample.aot ./ x64 / {{ target }} / component_sample.wasm
47+
3448check target = default-target :
3549 cargo check --profile={{ if target == " debug" {" dev" } else { target } }}
3650 cd src/ rust_wasm_samples && cargo check --profile={{ if target == " debug" {" dev" } else { target } }}
51+ cd src/ component_sample && cargo check --profile={{ if target == " debug" {" dev" } else { target } }}
3752 cd src/ wasm_runtime && cargo check --profile={{ if target == " debug" {" dev" } else { target } }}
3853
3954fmt-check :
4055 rustup toolchain install nightly -c rustfmt && cargo + nightly fmt -v --all -- --check
4156 cd src/ rust_wasm_samples && rustup toolchain install nightly -c rustfmt && cargo + nightly fmt -v --all -- --check
57+ cd src/ component_sample && rustup toolchain install nightly -c rustfmt && cargo + nightly fmt -v --all -- --check
4258 cd src/ wasm_runtime && rustup toolchain install nightly -c rustfmt && cargo + nightly fmt -v --all -- --check
43- fmt :
59+ fmt :
60+ rustup toolchain install nightly -c rustfmt
4461 cargo + nightly fmt --all
45- cd src/ rust_wasm_samples && cargo + nightly fmt
46- cd src/ wasm_runtime && cargo + nightly fmt
62+ cd src/ rust_wasm_samples && cargo + nightly fmt -v --all
63+ cd src/ component_sample && cargo + nightly fmt -v --all
64+ cd src/ wasm_runtime && cargo + nightly fmt -v --all
4765
4866clippy target = default-target : (check target)
4967 cargo clippy --profile={{ if target == " debug" {" dev" } else { target } }} --all-targets --all-features -- -D warnings
5068 cd src/ rust_wasm_samples && cargo clippy --profile={{ if target == " debug" {" dev" } else { target } }} --all-targets --all-features -- -D warnings
69+ cd src/ component_sample && cargo clippy --profile={{ if target == " debug" {" dev" } else { target } }} --all-targets --all-features -- -D warnings
5170 cd src/ wasm_runtime && cargo clippy --profile={{ if target == " debug" {" dev" } else { target } }} --all-targets --all-features -- -D warnings
5271
5372# TESTING
@@ -71,6 +90,9 @@ examples-ci target=default-target features="": (build-rust-wasm-examples target)
7190 cargo run {{ if features == " " {' ' } else {" --no-default-features -F function_call_metrics," + features } }} --profile={{ if target == " debug" {" dev" } else { target } }} --example metrics
7291 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
7392
93+ examples-components target = default-target features = " ": (build-rust-component-examples target)
94+ {{ wit-world }} cargo run {{ if features == " " {' ' } else {" --no-default-features -F " + features } }} --profile={{ if target == " debug" {" dev" } else { target } }} --example component_example
95+
7496# warning, compares to and then OVERWRITES the given baseline
7597bench-ci baseline target = default-target features = " ":
7698 cd src/ hyperlight_wasm && cargo bench --profile={{ if target == " debug" {" dev" } else { target } }} {{ if features == " " {' ' } else { " --features " + features } }} -- --verbose --save-baseline {{ baseline}}
0 commit comments