forked from eryx-org/eryx
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmise.toml
More file actions
708 lines (609 loc) · 23.8 KB
/
Copy pathmise.toml
File metadata and controls
708 lines (609 loc) · 23.8 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
[tools]
# Profile "default" includes rustc, rust-std, cargo, rust-docs, rustfmt, and clippy
rust = { version = "1.98", profile = "default" }
[tools."cargo:cargo-nextest"]
version = "0.9.143"
[tools."cargo:wasm-tools"]
version = "1.257.1"
[tools."cargo:cargo-rail"]
version = "0.22.1"
[tools."cargo:cargo-all-features"]
version = "1.12.0"
[tools."cargo:mdbook"]
version = "0.5.4"
[tools."cargo:mdbook-langtabs"]
version = "0.2.0"
[tools."cargo:wasm-bindgen-cli"]
version = "0.2.127"
# Note: WASI SDK is intentionally NOT in [tools] because adding it to PATH
# breaks host compilation (Rust picks up wasm clang for proc-macro builds).
# Instead, we install it on-demand via the ensure-wasi-sdk task.
[vars]
wasi_sdk_version = "wasi-sdk-33"
[tasks.check]
description = "Run cargo check"
run = "cargo check --workspace"
[tasks.build]
description = "Build all crates"
run = "cargo build --workspace"
[tasks.test]
description = "Run tests with embedded WASM"
depends = ["precompile-eryx-runtime-preinit"]
run = "cargo nextest run --workspace --features embedded"
[tasks.test-python]
description = "Run Python binding tests (delegates to crates/eryx-python/mise.toml)"
dir = "crates/eryx-python"
run = "mise run test"
[tasks.test-all]
description = "Run tests with all features"
depends = ["precompile-eryx-runtime-preinit"]
run = "cargo nextest run --workspace --all-features"
[tasks.lint]
description = "Run clippy lints"
depends = ["build-preinit"]
run = "cargo clippy --workspace --all-targets --all-features -- -D warnings"
[tasks.lint-fix]
description = "Auto-fix clippy warnings"
depends = ["build-preinit"]
run = "cargo clippy --fix --allow-dirty --workspace --all-targets --all-features"
[tasks.fmt]
description = "Format code"
run = "cargo fmt --all"
[tasks.fmt-check]
description = "Check code formatting"
run = "cargo fmt --all -- --check"
[tasks.doc]
description = "Generate documentation"
depends = ["build-preinit"]
run = "cargo doc --workspace --no-deps --all-features"
[tasks.doc-open]
description = "Generate and open documentation"
run = "cargo doc --workspace --no-deps --open"
[tasks.ci]
description = "Run all CI checks"
depends = ["fmt-check", "lint", "test"]
[tasks.unify]
description = "Unify workspace dependencies and prune dead features"
run = "cargo rail unify"
[tasks.unify-check]
description = "Check for dependency drift (CI)"
run = "cargo rail unify --check"
[tasks.affected]
description = "List affected crates"
run = "cargo rail affected"
[tasks.check-all-features]
description = "Check all feature combinations compile"
run = "cargo check-all-features"
[tasks.test-all-features]
description = "Test all feature combinations"
depends = ["build-eryx-runtime"]
run = "cargo test-all-features"
[tasks.clean]
description = "Clean build artifacts"
run = "cargo clean"
[tasks.setup-hooks]
description = "Install git hooks for pre-commit formatting"
run = """
git config core.hooksPath .githooks
echo "✓ Git hooks installed from .githooks/"
echo " Pre-commit hook will run 'mise run fmt' before each commit"
"""
[tasks.bump-version]
description = "Bump version using release-plz (e.g., mise run bump-version 0.3.0)"
run = "./scripts/bump-version.sh ${1:-}"
# =============================================================================
# Cache Detection Tasks
# =============================================================================
# These tasks help detect stale or problematic cached artifacts.
# Run `mise run check-caches` to check all cache layers at once.
[tasks.check-caches]
description = "Check all cache layers for potential staleness issues"
depends = [
"check-wasm-artifacts",
"check-embedded-cache",
"check-python-extension",
"check-cargo-timestamps",
"check-late-linking-cache",
]
run = """
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Cache check complete. Review any warnings above."
echo "To clean all caches: mise run clean-artifacts && cargo clean"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
"""
[tasks.check-wasm-artifacts]
description = "Check WASM/CWASM artifact timestamps vs source files"
run = """
echo "━━━ WASM Artifacts ━━━"
WASM="crates/eryx-runtime/runtime.wasm"
CWASM="crates/eryx-runtime/runtime.cwasm"
if [[ ! -f "$WASM" ]]; then
echo "⚠️ runtime.wasm does not exist - run 'mise run build-eryx-runtime'"
elif [[ ! -f "$CWASM" ]]; then
echo "⚠️ runtime.cwasm does not exist - run 'mise run precompile-eryx-runtime'"
else
WASM_TIME=$(stat -c %Y "$WASM" 2>/dev/null || stat -f %m "$WASM")
CWASM_TIME=$(stat -c %Y "$CWASM" 2>/dev/null || stat -f %m "$CWASM")
echo "runtime.wasm: $(ls -lh "$WASM" | awk '{print $5, $6, $7, $8}')"
echo "runtime.cwasm: $(ls -lh "$CWASM" | awk '{print $5, $6, $7, $8}')"
# Check if any source file is newer than wasm
NEWEST_SRC=$(find crates/eryx-wasm-runtime/src -name "*.rs" -newer "$WASM" 2>/dev/null | head -5)
if [[ -n "$NEWEST_SRC" ]]; then
echo "⚠️ Source files newer than runtime.wasm:"
echo "$NEWEST_SRC" | sed 's/^/ /'
echo " Run 'mise run build-eryx-runtime' to rebuild"
else
echo "✓ runtime.wasm is up-to-date with sources"
fi
if [[ "$WASM_TIME" -gt "$CWASM_TIME" ]]; then
echo "⚠️ runtime.wasm is newer than runtime.cwasm - run 'mise run precompile-eryx-runtime-preinit'"
else
echo "✓ runtime.cwasm is up-to-date (preinit version)"
fi
fi
# Check for non-preinit variant
CWASM_NO_PREINIT="crates/eryx-runtime/runtime-no-preinit.cwasm"
if [[ -f "$CWASM_NO_PREINIT" ]]; then
echo "runtime-no-preinit.cwasm: $(ls -lh "$CWASM_NO_PREINIT" | awk '{print $5, $6, $7, $8}')"
fi
echo ""
"""
[tasks.check-embedded-cache]
description = "Check embedded runtime cache in /tmp/eryx-embedded"
run = """
echo "━━━ Embedded Runtime Cache ━━━"
CACHE_DIR="${TMPDIR:-/tmp}/eryx-embedded"
if [[ ! -d "$CACHE_DIR" ]]; then
echo "✓ No embedded cache directory (will be created on first use)"
else
echo "Cache directory: $CACHE_DIR"
# List runtime files
RUNTIME_FILES=$(ls -la "$CACHE_DIR"/runtime-*.cwasm 2>/dev/null)
if [[ -n "$RUNTIME_FILES" ]]; then
echo "Cached runtimes:"
ls -lh "$CACHE_DIR"/runtime-*.cwasm 2>/dev/null | while read line; do
echo " $line"
done
# Count how many versions exist
COUNT=$(ls "$CACHE_DIR"/runtime-*.cwasm 2>/dev/null | wc -l)
if [[ "$COUNT" -gt 1 ]]; then
echo "⚠️ Multiple runtime versions cached ($COUNT files) - old versions can be cleaned"
fi
else
echo " No runtime files cached"
fi
# Check stdlib
if [[ -d "$CACHE_DIR/python-stdlib" ]]; then
STDLIB_SIZE=$(du -sh "$CACHE_DIR/python-stdlib" 2>/dev/null | cut -f1)
echo "Python stdlib: $STDLIB_SIZE"
fi
# Total size
TOTAL_SIZE=$(du -sh "$CACHE_DIR" 2>/dev/null | cut -f1)
echo "Total cache size: $TOTAL_SIZE"
fi
echo ""
"""
[tasks.check-python-extension]
description = "Check Python extension (.so) timestamps"
run = """
echo "━━━ Python Extension ━━━"
EXTENSION="crates/eryx-python/target/release/liberyx_python.so"
ABI3_EXT=$(find crates/eryx-python -name "_eryx*.so" -o -name "_eryx*.abi3.so" 2>/dev/null | head -1)
if [[ -n "$ABI3_EXT" && -f "$ABI3_EXT" ]]; then
echo "Extension: $ABI3_EXT"
echo " $(ls -lh "$ABI3_EXT" | awk '{print $5, $6, $7, $8}')"
# Check if eryx-wasm-runtime sources are newer
NEWEST_WASM_SRC=$(find crates/eryx-wasm-runtime/src -name "*.rs" -newer "$ABI3_EXT" 2>/dev/null | head -3)
NEWEST_ERYX_SRC=$(find crates/eryx/src -name "*.rs" -newer "$ABI3_EXT" 2>/dev/null | head -3)
NEWEST_PY_SRC=$(find crates/eryx-python/src -name "*.rs" -newer "$ABI3_EXT" 2>/dev/null | head -3)
if [[ -n "$NEWEST_WASM_SRC" ]]; then
echo "⚠️ eryx-wasm-runtime sources newer than extension:"
echo "$NEWEST_WASM_SRC" | sed 's/^/ /'
echo " The WASM runtime code has changed. Run:"
echo " 1. mise run build-eryx-runtime"
echo " 2. cd crates/eryx-python && maturin develop --release"
elif [[ -n "$NEWEST_ERYX_SRC" || -n "$NEWEST_PY_SRC" ]]; then
echo "⚠️ Rust sources newer than extension - run 'cd crates/eryx-python && maturin develop --release'"
else
echo "✓ Python extension is up-to-date"
fi
else
echo "⚠️ No Python extension found - run 'cd crates/eryx-python && maturin develop --release'"
fi
echo ""
"""
[tasks.check-cargo-timestamps]
description = "Check for cargo cache timestamp anomalies"
run = '''
echo "━━━ Cargo Cache Timestamps ━━━"
# Check if any .rlib files in target are newer than their source crates
ANOMALIES=""
for crate in eryx eryx-runtime eryx-wasm-runtime; do
CRATE_DIR="crates/$crate"
if [[ ! -d "$CRATE_DIR" ]]; then
continue
fi
# Find newest source file in crate (Linux stat syntax, fallback to macOS)
NEWEST_SRC=$(find "$CRATE_DIR/src" -name "*.rs" -type f -exec stat -c '%Y %n' {} \; 2>/dev/null | sort -rn | head -1)
if [[ -z "$NEWEST_SRC" ]]; then
NEWEST_SRC=$(find "$CRATE_DIR/src" -name "*.rs" -type f -exec stat -f '%m %N' {} \; 2>/dev/null | sort -rn | head -1)
fi
if [[ -z "$NEWEST_SRC" ]]; then
continue
fi
SRC_TIME=$(echo "$NEWEST_SRC" | cut -d' ' -f1)
# Find any .rlib for this crate that is newer than newest source
RLIB=$(find target -name "lib${crate//-/_}*.rlib" -type f 2>/dev/null | head -1)
if [[ -n "$RLIB" ]]; then
RLIB_TIME=$(stat -c '%Y' "$RLIB" 2>/dev/null || stat -f '%m' "$RLIB")
if [[ "$RLIB_TIME" -gt "$SRC_TIME" ]]; then
ANOMALIES="${ANOMALIES}
${crate}: .rlib newer than sources (cache may be stale)"
fi
fi
done
if [[ -n "$ANOMALIES" ]]; then
echo "⚠️ Timestamp anomalies detected (cached artifacts newer than sources):"
echo "$ANOMALIES"
echo ""
echo " This can happen after git checkout/pull or CI cache restore."
echo " Cargo should handle this correctly, but if you see stale behavior:"
echo " cargo clean -p eryx-wasm-runtime && mise run build-eryx-runtime"
else
echo "✓ No timestamp anomalies detected"
fi
echo ""
'''
[tasks.check-late-linking-cache]
description = "Check for stale late-linking artifacts in cargo OUT_DIR"
run = '''
echo "━━━ Late-Linking Artifacts ━━━"
# Late-linking artifacts are cached in target/*/build/eryx-runtime-*/out/
# If these are stale (e.g., old WIT interface without TCP/TLS), preinit fails
# with "type-checking export func" errors
CACHED_ARTIFACTS=$(find target -path "*/build/eryx-runtime-*/out/*.so.zst" 2>/dev/null)
if [[ -z "$CACHED_ARTIFACTS" ]]; then
echo "✓ No cached late-linking artifacts found"
else
echo "Found cached late-linking artifacts:"
echo "$CACHED_ARTIFACTS" | while read f; do
echo " $(ls -lh "$f" | awk '{print $5, $6, $7, $8, $9}')"
done
# Check if prebuilt artifacts exist and compare
PREBUILT="crates/eryx-runtime/prebuilt/liberyx_runtime.so.zst"
if [[ -f "$PREBUILT" ]]; then
PREBUILT_TIME=$(stat -c '%Y' "$PREBUILT" 2>/dev/null || stat -f '%m' "$PREBUILT")
STALE=""
for cached in $CACHED_ARTIFACTS; do
CACHED_TIME=$(stat -c '%Y' "$cached" 2>/dev/null || stat -f '%m' "$cached")
if [[ "$PREBUILT_TIME" -gt "$CACHED_TIME" ]]; then
STALE="yes"
break
fi
done
if [[ -n "$STALE" ]]; then
echo "⚠️ Cached artifacts are older than prebuilt artifacts"
echo " Run 'mise run clean-late-linking-cache' to clear them"
else
echo "✓ Cached artifacts appear up-to-date"
fi
else
echo " (no prebuilt artifacts to compare against)"
fi
fi
echo ""
'''
[tasks.clean-late-linking-cache]
description = "Clear stale late-linking artifacts from cargo OUT_DIR"
run = """
echo "Removing late-linking artifacts from cargo OUT_DIR..."
FOUND=$(find target -path "*/build/eryx-runtime-*/out/*.so.zst" 2>/dev/null)
if [[ -n "$FOUND" ]]; then
echo "$FOUND" | xargs rm -v
echo "✓ Late-linking cache cleared"
else
echo "✓ No cached late-linking artifacts found"
fi
"""
[tasks.clean-artifacts]
description = "Clean WASM artifacts and extracted stdlibs (simulate CI fresh state)"
run = """
echo "Removing WASM artifacts..."
rm -f crates/eryx-runtime/runtime.wasm
rm -f crates/eryx-runtime/runtime.cwasm
rm -f crates/eryx-runtime/runtime-no-preinit.cwasm
echo "Removing prebuilt artifacts..."
rm -rf crates/eryx-runtime/prebuilt/
echo "Removing extracted stdlib for eryx-wasm-runtime tests..."
rm -rf crates/eryx-wasm-runtime/tests/python-stdlib
rm -rf crates/eryx-wasm-runtime/tests/site-packages
rm -f crates/eryx-wasm-runtime/target/liberyx_runtime.so
echo "Removing system temp extracted resources..."
rm -rf "${TMPDIR:-/tmp}/eryx-embedded"
echo "Removing late-linking artifacts from cargo OUT_DIR..."
find target -path "*/build/eryx-runtime-*/out/*.so.zst" -delete 2>/dev/null || true
echo "✓ Artifacts cleaned. Run 'mise run setup' to rebuild."
"""
[tasks.build-eryx-runtime]
description = "Build the eryx-wasm-runtime and runtime.wasm"
depends = ["ensure-wasi-sdk"]
run = """
export WASI_SDK_PATH=$(mise where "github:WebAssembly/wasi-sdk@{{vars.wasi_sdk_version}}")
BUILD_ERYX_RUNTIME=1 cargo build --package eryx-runtime --release
"""
sources = [
"crates/eryx-wasm-runtime/src/**/*.rs",
"crates/eryx-wasm-runtime/clock_stubs.c",
"crates/eryx-wasm-runtime/Cargo.toml",
"crates/eryx-runtime/wit/**/*.wit",
]
outputs = ["crates/eryx-runtime/runtime.wasm"]
[tasks.build-preinit]
description = "Build preinit artifacts (liberyx_runtime.so.zst, etc.)"
depends = ["build-eryx-runtime"]
run = "cargo build --package eryx-runtime --features preinit --release"
[tasks.build-all]
description = "Build WASM component and Rust crates"
depends = ["build-eryx-runtime", "build"]
[tasks.bench]
description = "Run benchmarks"
depends = ["precompile-eryx-runtime-preinit"]
run = "cargo bench --package eryx --all-features"
[tasks.bench-save]
description = "Run benchmarks and save baseline"
depends = ["precompile-eryx-runtime-preinit"]
run = "cargo bench --package eryx --all-features -- --save-baseline main"
[tasks.precompile-eryx-runtime]
description = "Pre-compile eryx-runtime WASM to native code (without Python pre-init)"
depends = ["build-eryx-runtime"]
env = { ERYX_PRECOMPILE_BOOTSTRAP = "1" }
run = """
# Use ERYX_CPU_FEATURES for portable builds (default: native)
TARGET="${ERYX_CPU_FEATURES:-native}"
cargo run -p eryx-precompile --release -- compile \
crates/eryx-runtime/runtime.wasm \
--target "$TARGET" \
--output crates/eryx-runtime/runtime-no-preinit.cwasm \
--no-verify
"""
sources = ["crates/eryx-runtime/runtime.wasm"]
outputs = ["crates/eryx-runtime/runtime-no-preinit.cwasm"]
[tasks.precompile-eryx-runtime-preinit]
description = "Pre-initialize Python and pre-compile runtime (faster sessions)"
depends = ["build-eryx-runtime", "build-preinit", "setup-eryx-runtime-tests"]
env = { ERYX_PRECOMPILE_BOOTSTRAP = "1" }
run = """
# Use ERYX_CPU_FEATURES for portable builds (default: native)
# For Fly.io, set ERYX_CPU_FEATURES=x86-64-v3 (no AVX-512)
TARGET="${ERYX_CPU_FEATURES:-native}"
cargo run -p eryx-precompile --release -- compile \
crates/eryx-runtime/runtime.wasm \
--preinit \
--stdlib crates/eryx-wasm-runtime/tests/python-stdlib \
--target "$TARGET" \
--output crates/eryx-runtime/runtime.cwasm \
--no-verify
"""
sources = [
"crates/eryx-runtime/runtime.wasm",
"crates/eryx-wasm-runtime/tests/python-stdlib/encodings/__init__.py",
]
outputs = ["crates/eryx-runtime/runtime.cwasm"]
[tasks.setup]
description = "Set up development environment (build WASM, precompile, etc.)"
depends = ["precompile-eryx-runtime-preinit"]
run = """
echo "✓ Development environment ready!"
echo ""
echo "Available commands:"
echo " mise run test - Run tests (~0.1s with precompiled WASM)"
echo " mise run ci - Run all CI checks"
echo " mise run build-all - Build WASM and Rust crates"
"""
[tasks.build-all-precompiled]
description = "Build WASM, pre-compile it, and build Rust crates"
depends = ["build-eryx-runtime", "build"]
[tasks.msrv]
description = "Check compilation on minimum supported Rust version"
run = "cargo +1.91 check --workspace"
[tasks.example-demo]
description = "Run the demo example"
depends = ["build-eryx-runtime"]
run = "cargo run --example trace_events --features embedded"
[tasks.examples]
description = "Run all examples"
depends = ["precompile-eryx-runtime-preinit"]
run = """
echo "=== simple ==="
cargo run --example simple --features embedded --release
echo ""
echo "=== parallel_callbacks ==="
cargo run --example parallel_callbacks --features embedded --release
echo ""
echo "=== with_tracing ==="
cargo run --example with_tracing --features embedded --release
echo ""
echo "=== error_handling ==="
cargo run --example error_handling --features embedded --release
echo ""
echo "=== resource_limits ==="
cargo run --example resource_limits --features embedded --release
echo ""
echo "=== custom_library ==="
cargo run --example custom_library --features embedded --release
echo ""
echo "=== session_reuse ==="
cargo run --example session_reuse --features embedded --release
echo ""
echo "=== runtime_callbacks ==="
cargo run --example runtime_callbacks --features embedded --release
echo ""
echo "=== trace_events ==="
cargo run --example trace_events --features embedded --release
echo ""
echo "=== precompile ==="
cargo run --example precompile --release
echo ""
echo "=== embedded_runtime ==="
cargo run --example embedded_runtime --features embedded --release
echo ""
echo "✓ All examples completed!"
"""
[tasks.ensure-wasi-sdk]
description = "Install WASI SDK if not present"
run = """
WASI_SDK_SPEC="github:WebAssembly/wasi-sdk@{{vars.wasi_sdk_version}}"
if ! mise where "$WASI_SDK_SPEC" 2>/dev/null; then
echo "Installing WASI SDK ({{vars.wasi_sdk_version}})..."
mise install "$WASI_SDK_SPEC"
fi
WASI_SDK_PATH=$(mise where "$WASI_SDK_SPEC")
if [ ! -f "$WASI_SDK_PATH/bin/clang" ]; then
echo "ERROR: WASI SDK installation incomplete - clang not found"
exit 1
fi
echo "Using WASI SDK at: $WASI_SDK_PATH"
"""
[tasks.setup-eryx-runtime-tests]
description = "Extract Python stdlib and copy liberyx_runtime.so for eryx-wasm-runtime tests"
depends = ["build-eryx-runtime"]
dir = "crates/eryx-wasm-runtime"
run = """
mkdir -p tests/python-stdlib tests/site-packages target
# Extract Python stdlib
PYTHON_LIB="../eryx/python-stdlib.tar.zst"
if [[ ! -f "$PYTHON_LIB" ]]; then
echo "Error: python-stdlib.tar.zst not found at $PYTHON_LIB"
exit 1
fi
echo "Extracting $PYTHON_LIB"
# Extract to a temp location first, then move contents (archive has python-stdlib/ prefix)
rm -rf tests/python-stdlib-tmp
mkdir -p tests/python-stdlib-tmp
tar -xf "$PYTHON_LIB" -C tests/python-stdlib-tmp
# Move contents from nested directory to final location
rm -rf tests/python-stdlib
mv tests/python-stdlib-tmp/python-stdlib tests/python-stdlib
rm -rf tests/python-stdlib-tmp
# Copy liberyx_runtime.so from build output (skip if already exists, e.g. in CI)
if [[ -f "target/liberyx_runtime.so" ]]; then
echo "liberyx_runtime.so already exists in target/, skipping copy"
else
# Search in both release and debug build directories
OUT_DIR=$(find ../../target -path "*/eryx-runtime-*/out/liberyx_runtime.so" -type f 2>/dev/null | head -1)
if [[ -z "$OUT_DIR" ]]; then
echo "Error: liberyx_runtime.so not found in target. Run 'mise run build-eryx-runtime' first."
exit 1
fi
echo "Copying $OUT_DIR to target/"
cp "$OUT_DIR" target/liberyx_runtime.so
fi
"""
[tasks."book:build"]
description = "Build the mdbook documentation"
dir = "book"
run = "mdbook build"
[tasks."book:serve"]
description = "Serve the mdbook documentation locally"
dir = "book"
run = "mdbook serve"
[tasks."book:test"]
description = "Test Rust code blocks in the book"
depends = ["build"]
dir = "book"
run = "mdbook test -L ../target/debug/deps"
[tasks."book:test-python"]
description = "Test Python code blocks in the book"
depends = ["test-python"]
dir = "book"
run = "python3 scripts/test_examples.py"
[tasks."book:test-all"]
description = "Test both Rust and Python code blocks in the book"
depends = ["book:test", "book:test-python"]
[tasks.build-linker-wasm]
description = "Build the eryx-linker-wasm crate for browser use (wasm-bindgen)"
run = """
#!/usr/bin/env bash
set -euo pipefail
cargo build --package eryx-linker-wasm --target wasm32-unknown-unknown --release
wasm-bindgen target/wasm32-unknown-unknown/release/eryx_linker_wasm.wasm \
--target web \
--out-dir js/demo/src/lib/linker-wasm \
--out-name linker
# Optimize the WASM binary if wasm-opt is available
if command -v wasm-opt &>/dev/null; then
wasm-opt -Oz js/demo/src/lib/linker-wasm/linker_bg.wasm \
-o js/demo/src/lib/linker-wasm/linker_bg.wasm
fi
"""
sources = ["crates/eryx-linker-wasm/src/**/*.rs", "crates/eryx-linker-wasm/Cargo.toml"]
outputs = ["js/demo/src/lib/linker-wasm/linker_bg.wasm", "js/demo/src/lib/linker-wasm/linker.js"]
[tasks.copy-base-libs]
description = "Copy compressed base libraries to demo public/ for browser fetching"
run = """
#!/usr/bin/env bash
set -euo pipefail
DEST=js/demo/public/libs
mkdir -p "$DEST"
# Base libraries from libs/
for f in libc.so.zst libc++.so.zst libc++abi.so.zst libpython3.14.so.zst \
libwasi-emulated-mman.so.zst libwasi-emulated-process-clocks.so.zst \
libwasi-emulated-getpid.so.zst libwasi-emulated-signal.so.zst \
wasi_snapshot_preview1.reactor.wasm.zst; do
cp "crates/eryx-runtime/libs/$f" "$DEST/$f"
done
# Prebuilt runtime libraries
cp crates/eryx-runtime/prebuilt/liberyx_runtime.so.zst "$DEST/"
cp crates/eryx-runtime/prebuilt/liberyx_bindings.so.zst "$DEST/"
echo "Copied $(ls "$DEST" | wc -l) files to $DEST"
"""
[tasks.download-numpy-wasi]
description = "Download numpy WASI wheel for custom runtime demo"
run = """
mkdir -p crates/eryx-server/packages
curl -sL https://github.com/dicej/wasi-wheels/releases/download/v0.0.2/numpy-wasi.tar.gz \
-o crates/eryx-server/packages/numpy-wasi.tar.gz
"""
[tasks.build-numpy-runtime]
description = "Build a custom runtime.cwasm with numpy baked in (demo)"
depends = ["download-numpy-wasi", "build-eryx-runtime", "build-preinit", "setup-eryx-runtime-tests"]
env = { ERYX_PRECOMPILE_BOOTSTRAP = "1" }
run = """
TARGET="${ERYX_CPU_FEATURES:-native}"
cargo run -p eryx-precompile --release -- compile \
crates/eryx-runtime/runtime.wasm \
--preinit \
--stdlib crates/eryx-wasm-runtime/tests/python-stdlib \
--package crates/eryx-server/packages/numpy-wasi.tar.gz \
--import numpy \
--target "$TARGET" \
--output crates/eryx-server/runtime.cwasm \
--no-verify
"""
[tasks.build-numpy-server-image]
description = "Build Docker image with numpy runtime (demo)"
depends = ["build-numpy-runtime"]
run = """
docker build -f crates/eryx-server/Dockerfile \
--build-arg RUNTIME_SOURCE=custom \
--build-arg RUNTIME_CWASM=crates/eryx-server/runtime.cwasm \
-t eryx-server:custom \
.
"""
[tasks.build-server-image-ci]
description = "Build Docker image using pre-built runtime.cwasm (simulates CI)"
depends = ["precompile-eryx-runtime-preinit"]
run = """
cp crates/eryx-runtime/runtime.cwasm crates/eryx-server/runtime.cwasm
docker build -f crates/eryx-server/Dockerfile \
--build-arg RUNTIME_SOURCE=custom \
--build-arg RUNTIME_CWASM=crates/eryx-server/runtime.cwasm \
-t eryx-server:ci-test \
.
rm -f crates/eryx-server/runtime.cwasm
"""
[tasks.test-eryx-runtime]
description = "Run eryx-wasm-runtime integration tests"
depends = ["build-eryx-runtime", "setup-eryx-runtime-tests"]
run = "cargo test --package eryx-wasm-runtime --test runtime_test -- --nocapture"