Skip to content

Commit de13bd3

Browse files
committed
trying stale cahce cleanup
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
1 parent e9b6331 commit de13bd3

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

src/wasm_sandbox/Justfile

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,56 @@ guest-compile-wit: ensure-tools
3232
# Invalidate cargo caches that embed the WIT signature.
3333
# Without this, cargo won't detect that sandbox-world.wasm changed
3434
# and SDKs will fail at runtime with "vector parameter missing length".
35+
# Also cleans hyperlight-host artifacts + hls/ surrogate dir to avoid
36+
# inconsistent state on Windows after partial cache restore.
3537
invalidate-wit-caches:
3638
-{{rmrf}} {{repo-root}}/target/hyperlight-wasm-runtime
39+
-{{rmrf}} {{repo-root}}/target/hls
3740
-{{rmrf}} {{repo-root}}/target/debug/build/hyperlight-wasm-*
3841
-{{rmrf}} {{repo-root}}/target/debug/.fingerprint/hyperlight-wasm-*
42+
-{{rmrf}} {{repo-root}}/target/debug/build/hyperlight-host-*
43+
-{{rmrf}} {{repo-root}}/target/debug/.fingerprint/hyperlight-host-*
3944
-{{rmrf}} {{repo-root}}/target/release/build/hyperlight-wasm-*
4045
-{{rmrf}} {{repo-root}}/target/release/.fingerprint/hyperlight-wasm-*
46+
-{{rmrf}} {{repo-root}}/target/release/build/hyperlight-host-*
47+
-{{rmrf}} {{repo-root}}/target/release/.fingerprint/hyperlight-host-*
4148
-{{rmrf}} {{repo-root}}/src/sdk/python/wasm_backend/target/hyperlight-wasm-runtime
4249
-{{rmrf}} {{repo-root}}/src/sdk/python/wasm_backend/target/debug/build/hyperlight-wasm-*
4350
-{{rmrf}} {{repo-root}}/src/sdk/python/wasm_backend/target/debug/.fingerprint/hyperlight-wasm-*
4451
-{{rmrf}} {{repo-root}}/src/sdk/python/wasm_backend/target/release/build/hyperlight-wasm-*
4552
-{{rmrf}} {{repo-root}}/src/sdk/python/wasm_backend/target/release/.fingerprint/hyperlight-wasm-*
4653

54+
# Only clean when rust-cache left stale state (fingerprints exist but runtime binary missing).
55+
[unix]
56+
_clean-stale-wasm:
57+
#!/usr/bin/env bash
58+
for profile in debug release; do
59+
if compgen -G "{{repo-root}}/target/$profile/build/hyperlight-wasm-*" > /dev/null && \
60+
[ ! -f "{{repo-root}}/target/hyperlight-wasm-runtime/x86_64-hyperlight-none/$profile/hyperlight-wasm-runtime" ]; then
61+
echo "Cleaning stale hyperlight-wasm $profile build artifacts..."
62+
just wasm invalidate-wit-caches
63+
break
64+
fi
65+
done
66+
67+
[windows]
68+
_clean-stale-wasm:
69+
foreach ($profile in @('debug', 'release')) { \
70+
$bp = '{{repo-root}}/target/' + $profile + '/build'; \
71+
$rp = '{{repo-root}}/target/hyperlight-wasm-runtime/x86_64-hyperlight-none/' + $profile + '/hyperlight-wasm-runtime'; \
72+
if ((Get-ChildItem -Path $bp -Filter 'hyperlight-wasm-*' -ErrorAction SilentlyContinue) -and \
73+
-not (Test-Path $rp)) { \
74+
Write-Host ('Cleaning stale hyperlight-wasm ' + $profile + ' build artifacts...'); \
75+
just wasm invalidate-wit-caches; \
76+
break; \
77+
} \
78+
}
79+
4780
guest-build-aot target=default-target: guest-build-wasm ensure-tools
4881
hyperlight-wasm-aot compile --component \
4982
{{repo-root}}/src/wasm_sandbox/guests/python/python-sandbox.wasm {{repo-root}}/src/wasm_sandbox/guests/python/python-sandbox.aot
5083

51-
guest-build target=default-target: (guest-build-wasm) (guest-compile-wit) invalidate-wit-caches (guest-build-aot target)
84+
guest-build target=default-target: (guest-build-wasm) (guest-compile-wit) (guest-build-aot target)
5285

5386
js-guest-build-wasm: (js-guest-install)
5487
cd {{repo-root}}/src/wasm_sandbox/guests/javascript && npm run build
@@ -62,7 +95,7 @@ js-guest-build: js-guest-build-wasm js-guest-build-aot
6295
js-guest-install:
6396
cd {{repo-root}}/src/wasm_sandbox/guests/javascript && npm install
6497

65-
build target=default-target: (guest-build target) (js-guest-build)
98+
build target=default-target: _clean-stale-wasm (guest-build target) (js-guest-build)
6699
cargo build --manifest-path {{repo-root}}/src/wasm_sandbox/Cargo.toml --profile={{ if target == "debug" {"dev"} else { target } }}
67100

68101
#### EXAMPLES ####

0 commit comments

Comments
 (0)