wasvy 0.0.9

WASI-powered modding for the Bevy engine
Documentation
# TIP: run the command `just -l` to get an overview

# Run an example host app
[group("examples")]
[arg("app", pattern="^(basic|components|custom_codec)$")]
run app *args:
	cargo run -p {{app}}_example_app --features bevy/file_watcher {{args}}

# Run the wasvy tui
[group("examples")]
cli *args:
	cargo run -p wasvy_cli -- {{args}}

# Build an example guest rust mod to wasm and place it in the shared assets directory
[group("examples")]
[arg("mod", pattern="^(basic|components)$")]
build-example-rust mod:
	cargo build --release --target wasm32-wasip2 -p {{mod}}_example_mod
	mkdir -p ./examples/assets/mods
	mv ./target/wasm32-wasip2/release/{{mod}}_example_mod.wasm ./examples/assets/mods/{{mod}}_example_mod.wasm

# Build the Python example mod.
[group("examples")]
[working-directory("examples/mods/python/src")]
build-example-python:
	poetry run componentize-py --wit-path ../wit/ --world example componentize app -o ../../../assets/mods/python.wasm

# Generate bindings for the Python example mod.
[group("examples")]
[working-directory("examples/python_example")]
generate-bindings-python:
	rm -rf ./src/componentize_py_async_support
	rm -rf ./src/wit_world
	rm -f ./src/componentize_py_runtime.pyi
	rm -f ./src/componentize_py_types.py
	rm -f ./src/poll_loop.py
	poetry run componentize-py --wit-path wit/ --world example bindings src

# Build the Go example mod.
[group("examples")]
[working-directory("examples/mods/go/src")]
[env("GOARCH", "wasm")]
[env("GOOS", "wasip1")]
build-example-go:
	go build -o core.wasm -buildmode=c-shared -ldflags=-checklinkname=0
	wasm-tools component embed -w example ../wit/ core.wasm -o core-with-wit.wasm
	wasm-tools component new --adapt ../wasi_snapshot_preview1.reactor.wasm core-with-wit.wasm -o go.wasm

# Generate bindings for the Go example mod.
[group("examples")]
[working-directory("examples/mods/go/src")]
generate-bindings-go:
	wit-bindgen go -w example ../wit/

# Enable repository git hooks.
[group("setup")]
enable-git-hooks:
	git config core.hooksPath .githooks
	chmod +x .githooks/pre-push

# Build the ECS WIT package.
[group("chores")]
build-wasvy-ecs:
	wkg wit build --wit-dir ./wit/

# Publish the ECS package to wa.dev.
[group("chores")]
publish-wasvy-ecs file_path version:
	wkg publish --package wasvy:ecs@{{version}} {{file_path}} --registry wa.dev

# Replace the existing (1.95.0) rust toolchain version with a new one.
[group("chores")]
[arg("new", pattern="^\\d+\\.\\d+\\.\\d+$")]
bump-toolchain new:
	rg -l -g '!.?*' -g '.githooks/**' -g '.github/**' 'rust' . | xargs sed -i "/rust/s/1.95.0/{{new}}/g"

# Replace the existing (0.19.0) bevy version with a new one.
[group("chores")]
[arg("new", pattern="^\\d+\\.\\d+\\.\\d+$")]
bump-bevy new:
	rg -l -g '!Cargo.lock' 'bevy' . | xargs sed -i "/bevy/s/0.19.0/{{new}}/g"
	cargo check

# Replace the existing (0.0.9) wasvy version with a new one.
[group("chores")]
[arg("new", pattern="^\\d+\\.\\d+\\.\\d+$")]
bump-version new:
	rg -l -g '!Cargo.lock' 'version' . | xargs sed -i "/version/s/0.0.9/{{new}}/g"
	cargo check

# Publishes all crates
[group("chores")]
[confirm]
publish:
	# CI
	cargo test --workspace --all-features
	cargo clippy --workspace --all-targets --all-features -- -D warnings
	cargo fmt --all -- --check
	RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --workspace --all-features

	# Publish
	cargo publish -p wasvy_macros
	cargo publish -p wasvy_cli
	cargo publish -p wasvy
	cargo publish -p wasvy_mock