Skip to content

Commit d11a78b

Browse files
build(canvas-wasm): retry past the skia-bindings prebuilt emscripten defect
`BinariesConfig::commit_to_cargo` copies `lib<x>.wasm.a` onto `lib<x>.a` for every emscripten target, because Skia's wasm GN toolchain emits that suffix since milestone 148. The published prebuilt archives ship those libraries already named `lib<x>.a`, so the copy panics on a missing source before anything is compiled. The library list is derived from the enabled features rather than from whether ninja ran, so only feature sets pulling in textlayout or svg are affected — which is exactly this crate's, and exactly the wasm32-unknown-emscripten combo published for it. Present in every skia-bindings from 0.97.0 through 0.99.0, so no version choice avoids it. Seeding the names the build script expects and building again is an identity operation: it copies each seeded file straight back onto the file it was copied from, so nothing that gets linked changes. Verified from a clean build directory — the first attempt panics once, the retry links, and the resulting module initializes under node with `_init`, `HEAPU8` and `UTF8ToString` all present, which is what the package's node smoke test asserts. Forcing a source build instead is not an alternative: Skia m150 wants the four-argument split-64-bit `glClientWaitSync`, while the pinned emsdk 5.0.0 declares the three-argument `GLuint64` form, and the WebGL interface fails to compile. Remove this once commit_to_cargo tolerates an absent `.wasm.a`.
1 parent 2197b18 commit d11a78b

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

crates/grida-canvas-wasm/justfile

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@
55
# Keep this inline (vs. a separate recipe) so the sourced `emsdk_env.sh` affects the same shell.
66
_wasm32_unknown_emscripten_env := "rustup target add wasm32-unknown-emscripten; (cd ../.. && ./bin/activate-emsdk); . ../../third_party/externals/emsdk/emsdk_env.sh; command -v emcc >/dev/null 2>&1; export CC=emcc CXX=em++ AR=emar"
77

8+
# Retry snippet for a skia-bindings defect that makes prebuilt emscripten
9+
# binaries unusable, so `cargo build` has to be attempted twice.
10+
#
11+
# `BinariesConfig::commit_to_cargo` copies `lib<x>.wasm.a` onto `lib<x>.a` for
12+
# every emscripten target, because Skia's wasm GN toolchain emits that suffix
13+
# since milestone 148. The published prebuilt archives ship those libraries
14+
# already named `lib<x>.a`, so the copy panics on a missing source before a
15+
# single line is compiled. The library list comes from the enabled features,
16+
# not from whether ninja ran, so this only bites feature sets pulling in
17+
# textlayout or svg — which is exactly this crate's. Present in every
18+
# skia-bindings from 0.97.0 through 0.99.0; no version choice avoids it.
19+
#
20+
# Seeding the expected names is an identity operation: the build script copies
21+
# each seeded file straight back onto the file it was copied from, so nothing
22+
# that gets linked changes. Remove this once commit_to_cargo tolerates an
23+
# absent `.wasm.a`.
24+
_seed_emscripten_archives := "for f in ../../target/wasm32-unknown-emscripten/*/build/skia-bindings-*/out/skia/lib*.a; do [ -e \"$f\" ] || continue; [ -e \"${f%.a}.wasm.a\" ] || cp \"$f\" \"${f%.a}.wasm.a\"; done"
25+
826
# Default recipe - shows available commands
927
default:
1028
@echo "🚀 Grida Canvas WASM Build System"
@@ -88,7 +106,8 @@ _build_wasm32_unknown_emscripten_debug:
88106
@bash -c 'set -euo pipefail; \
89107
{{_wasm32_unknown_emscripten_env}}; \
90108
echo "🧰 $(emcc --version | { IFS= read -r l; echo "$l"; })"; \
91-
time cargo build --target wasm32-unknown-emscripten'
109+
time { cargo build --target wasm32-unknown-emscripten \
110+
|| { {{_seed_emscripten_archives}}; cargo build --target wasm32-unknown-emscripten; }; }'
92111
@echo "✅ Build completed successfully!"
93112
@echo "📁 Output file: ../../target/wasm32-unknown-emscripten/debug/grida_canvas_wasm.wasm"
94113
@echo "🎉 Grida Canvas WASM is ready for use!"
@@ -99,7 +118,8 @@ _build_wasm32_unknown_emscripten_release:
99118
@bash -c 'set -euo pipefail; \
100119
{{_wasm32_unknown_emscripten_env}}; \
101120
echo "🧰 $(emcc --version | { IFS= read -r l; echo "$l"; })"; \
102-
time cargo build --release --target wasm32-unknown-emscripten'
121+
time { cargo build --release --target wasm32-unknown-emscripten \
122+
|| { {{_seed_emscripten_archives}}; cargo build --release --target wasm32-unknown-emscripten; }; }'
103123
@echo "✅ Production build completed successfully!"
104124
@echo "📁 Output file: ../../target/wasm32-unknown-emscripten/release/grida_canvas_wasm.wasm"
105125
@echo "⚡ Production optimizations applied:"

0 commit comments

Comments
 (0)