-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjustfile
More file actions
209 lines (168 loc) · 6.83 KB
/
justfile
File metadata and controls
209 lines (168 loc) · 6.83 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
set dotenv-load
# Show help
default:
@just --list
# Initialize the .env file tracking the WASI SDK version
init-env-file:
cp .env.original .env
cat .env
@echo ""
@echo "Currently, in .env file, WASI_OS=$WASI_OS and WASI_ARCH=$WASI_ARCH, please update them if needed."
#Download the WASI SDK into ./c_deps/wasi-sdk folder - run `just init-env-file` before
dl-wasi-sdk:
#!/usr/bin/env bash
mkdir -p c_deps
FILENAME=wasi-sdk-${WASI_VERSION_FULL}-${WASI_ARCH}-${WASI_OS}.tar.gz
curl -L -o c_deps/${FILENAME} https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/${FILENAME}
tar -C c_deps -xvf c_deps/${FILENAME}
rm -rf c_deps/wasi-sdk
mv c_deps/wasi-sdk-${WASI_VERSION_FULL}-${WASI_ARCH}-${WASI_OS} c_deps/wasi-sdk
# Generate the C bindings for the plugin
c-wit-bindgen-plugin plugin:
wit-bindgen c ./crates/pluginlab/wit --world plugin-api --out-dir ./c_modules/{{plugin}}
# Generate the C bindings for all plugins
c-wit-bindgen-plugins:
#!/usr/bin/env bash
just list-c-plugins|xargs -I {} just c-wit-bindgen-plugin {}
# Build a specific C plugin
build-c-plugin plugin:
#!/usr/bin/env bash
just c-wit-bindgen-plugin {{plugin}}
# Compile a WebAssmbly module (P1)
./c_deps/wasi-sdk/bin/clang ./c_modules/{{plugin}}/component.c ./c_modules/{{plugin}}/plugin_api.c ./c_modules/{{plugin}}/plugin_api_component_type.o -o ./c_modules/{{plugin}}/{{plugin}}-c.module.p1.wasm -mexec-model=reactor
# Convert the WebAssembly module (P1) to a WebAssembly component (P2)
wasm-tools component new ./c_modules/{{plugin}}/{{plugin}}-c.module.p1.wasm -o ./c_modules/{{plugin}}/{{plugin}}-c.wasm
# Build all C plugins
build-c-plugins:
#!/usr/bin/env bash
just list-c-plugins|xargs -I {} just build-c-plugin {}
# Prepare the wit files for Go
prepare-wit-files-for-go:
#!/usr/bin/env bash
./scripts/prepare-wit-files.sh -i crates/pluginlab/wit -o go_modules/wit -s "SPECIFIC TinyGo"
# Bundle wit files into a single file `repl:api.wasm`
go-wit-build: prepare-wit-files-for-go
#!/usr/bin/env bash
cd go_modules/
wkg wit build
# Generate Go bindings for the plugin
go-wit-bindgen-plugin plugin: go-wit-build
#!/usr/bin/env bash
cd go_modules/{{plugin}}
rm -rf internal
go tool wit-bindgen-go generate --world plugin-api --out internal ../repl:api.wasm
# Generate Go bindings for all plugins
go-wit-bindgen-plugins:
#!/usr/bin/env bash
just list-go-plugins|xargs -I {} just go-wit-bindgen-plugin {}
# Build a specific Go plugin
build-go-plugin plugin:
#!/usr/bin/env bash
just go-wit-bindgen-plugin {{plugin}}
cd go_modules/{{plugin}}
tinygo build -target=wasip2 --wit-package ../repl:api.wasm --wit-world plugin-api -o {{plugin}}-go.wasm main.go
# Build all Go plugins
build-go-plugins:
#!/usr/bin/env bash
just list-go-plugins|xargs -I {} just build-go-plugin {}
# List all Go plugins
list-go-plugins:
#!/usr/bin/env bash
ls -1 go_modules|grep plugin-
# Build all rust plugins in debug mode
build-rust-plugins:
#!/usr/bin/env bash
just list-rust-plugins|xargs -I {} cargo component build -p {}
# Build all rust plugins in release mode
build-rust-plugins-release:
#!/usr/bin/env bash
just list-rust-plugins|xargs -I {} cargo component build --release -p {}
wasi-sdk-name:
@echo wasi-sdk-${WASI_VERSION_FULL}-${WASI_ARCH}-${WASI_OS}.tar.gz
# Build all crates with appropriate commands
build: build-plugins
just build-pluginlab
# Build all crates in release mode
build-release: build-plugins-release
just build-pluginlab-release
# Build all plugins in debug mode
build-plugins:
#!/usr/bin/env bash
just build-repl-logic-guest
just build-rust-plugins
just build-c-plugins
just build-go-plugins
# Build all plugins in release mode
build-plugins-release:
#!/usr/bin/env bash
just build-repl-logic-guest-release
just build-rust-plugins-release
just build-c-plugins
just build-go-plugins
# Build a specific plugin
build-plugin plugin:
cargo component build -p {{plugin}}
# Build a specific plugin in release mode
build-plugin-release plugin:
cargo component build --release -p {{plugin}}
# Build the pluginlab (normal Rust build)
build-pluginlab:
cargo build -p pluginlab
# Build the pluginlab in release mode
build-pluginlab-release:
cargo build --release -p pluginlab
# Publish the pluginlab crate
publish-pluginlab:
cargo publish -p pluginlab
# Publish the pluginlab crate (dry run)
publish-pluginlab-dry-run:
cargo publish --dry-run -p pluginlab
# Build the REPL logic guest as a component
build-repl-logic-guest:
cargo component build -p repl-logic-guest
# Build the REPL logic guest as a component in release mode
build-repl-logic-guest-release:
cargo component build --release -p repl-logic-guest
# Clean all build artifacts
clean:
cargo clean
cargo component clean
# List all the rust plugins
list-rust-plugins:
#!/usr/bin/env bash
ls -1 crates|grep plugin-
# List all the C plugins
list-c-plugins:
#!/usr/bin/env bash
ls -1 c_modules|grep plugin-
# Run the tests for the pluginlab
test: build-repl-logic-guest build-plugins prepare-fixtures
cargo test
# Run the tests for the pluginlab with no parallelism
test-mono: build-repl-logic-guest build-plugins prepare-fixtures
cargo test --jobs 1
# Run the e2e tests for the pluginlab
test-e2e-pluginlab: build-repl-logic-guest build-plugins prepare-fixtures
cargo test -p pluginlab
# Run the e2e tests for the pluginlab with no capture
test-e2e-pluginlab-nocapture: build-repl-logic-guest build-plugins prepare-fixtures
cargo test -p pluginlab -- --nocapture
# Run the e2e tests for the pluginlab retrieving the plugins from the HTTP server - launch to check for breaking changes
test-e2e-pluginlab-http-latest: build-repl-logic-guest build-plugins prepare-fixtures
WASM_TARGET_DIR=https://topheman.github.io/webassembly-component-model-experiments/plugins cargo test -p pluginlab
# Run the e2e tests for the pluginlab retrieving the plugins from the HTTP server - launch to check for breaking changes
test-e2e-pluginlab-http-latest-nocapture: build-repl-logic-guest build-plugins prepare-fixtures
WASM_TARGET_DIR=https://topheman.github.io/webassembly-component-model-experiments/plugins cargo test -p pluginlab -- --nocapture
# Prepare the fixtures for the e2e tests
prepare-fixtures:
mkdir -p tmp/filesystem
rm -rf tmp/filesystem/*
cp -r fixtures/filesystem tmp
mv tmp/filesystem/README.rust.md tmp/filesystem/README.md
rm tmp/filesystem/README.browser.md
# Copy wasm files into /public/plugins of the web host - debug mode
web-host-prepare-wasm-files-debug:
./scripts/prepare-wasm-files.sh --mode debug
# Copy wasm files into /public/plugins of the web host - release mode
web-host-prepare-wasm-files-release:
./scripts/prepare-wasm-files.sh --mode release