-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
51 lines (39 loc) · 1.7 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# The wick command to use for this project (usually just "wick" but can be a local path during development)
wick := "wick"
# Get the crate name from the Cargo.toml file (this uses wick instead of {{wick}} due to justfile limitations)
crate_name := `wick query -f Cargo.toml '.package.name'`
# Convert crate name to snake case for rust naming conventions.
project_name := snakecase(crate_name)
# The target to build for release.
build_target := "wasm32-unknown-unknown"
# The target to build for debug (wasm32-wasi can give easy access to println & STDIO for debugging)
debug_target := "wasm32-wasi"
root_dir:=`cargo metadata --format-version=1 | wick query --type json -r '.workspace_root'`
# Build and sign a WebAssembly component implementation
build: setup
cargo build --release --target="{{build_target}}"
cp "{{root_dir}}/target/{{build_target}}/release/{{project_name}}.wasm" ./build/component.wasm
{{wick}} wasm sign ./build/component.wasm component.wick
# Build a debug version of a WebAssembly component
debug: setup
cargo +nightly build --target="{{debug_target}}"
cp "{{root_dir}}/target/{{debug_target}}/debug/{{project_name}}.wasm" ./build/component.wasm
{{wick}} wasm sign ./build/component.wasm component.wick
# Echo variables used by this justfile
debug-justfile:
@echo "Wick command: {{wick}}"
@echo "---"
@echo "Crate name: {{crate_name}}"
@echo "Crate name (rustified): {{project_name}}"
@echo "---"
@echo "Build target: {{build_target}}"
@echo "Debug target: {{debug_target}}"
# Setup any environment needed for the build
setup:
mkdir -p build
# Run tests
test: build
{{wick}} test component.wick
# Clean the project directory
clean:
cargo clean