Skip to content

Commit 8cfb878

Browse files
authored
Merge pull request #71 from element-hq/langley/update-wasm-script
Update rust sdk and improve script
2 parents ed6c392 + be14f07 commit 8cfb878

File tree

10 files changed

+148
-1407
lines changed

10 files changed

+148
-1407
lines changed

build-wasm-bindings.sh

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,51 @@ yarn ubrn:clean
66
echo "==> Step 2: Checking out..."
77
yarn ubrn:checkout
88

9-
echo "==> Step 3: Fetching full git history for patch application..."
9+
echo "==> Step 3: Resetting any modifications after checkout..."
10+
git -C rust_modules/matrix-rust-sdk reset --hard HEAD
11+
echo " ✓ Repository clean"
12+
13+
echo "==> Step 4: Fetching full git history for patch application..."
1014
git -C rust_modules/matrix-rust-sdk fetch --unshallow
1115

12-
echo "==> Step 4: Applying patches..."
13-
cd rust_modules/matrix-rust-sdk && git apply ../../patches/0001-Fix-uniffi-and-wasm-build.patch && git apply ../../patches/0001-Fix-wasm-default-features.patch && cd ../..
14-
echo " ✓ Patches applied successfully"
16+
echo "==> Step 5: Applying uniffi downgrade patch..."
17+
if git -C rust_modules/matrix-rust-sdk apply ../../patches/0001-Downgrade-uniffi-to-0.29.4.patch; then
18+
echo " ✓ Patch applied (uniffi downgrade to 0.29.4)"
19+
else
20+
echo " ✗ Patch failed!"
21+
exit 1
22+
fi
1523

16-
echo "==> Step 5: Removing bindings/wasm from Cargo.toml..."
24+
echo "==> Step 6: Removing bindings/wasm from workspace..."
25+
# Remove the non-existent bindings/wasm from workspace members
1726
sed -i.bak '/bindings\/wasm/d' rust_modules/matrix-rust-sdk/Cargo.toml
27+
echo " ✓ Removed from workspace"
1828

19-
echo "==> Step 6: Building web (first pass, expected to fail)..."
20-
yarn ubrn:web:build:release || true
29+
echo "==> Step 7: Building web (first pass to generate wasm bindings)..."
30+
yarn ubrn:web:build:release || echo " (First pass may have warnings)"
2131

22-
echo "==> Step 7: Adding bindings/wasm back to Cargo.toml..."
23-
sed -i.bak '/uniffi-bindgen/a\
32+
echo "==> Step 8: Adding bindings/wasm back to workspace..."
33+
# Add bindings/wasm back to workspace members now that it exists
34+
sed -i.bak '/"xtask",/a\
2435
"bindings/wasm",
2536
' rust_modules/matrix-rust-sdk/Cargo.toml
37+
echo " ✓ Added back to workspace"
2638

27-
echo "==> Step 8: Building web (second pass, should succeed)..."
39+
echo "==> Step 9: Building web (second pass with complete workspace)..."
2840
set -e
2941
yarn ubrn:web:build:release
3042

31-
echo "==> Step 9: Fixing index.web.ts import..."
32-
INDEX_FILE="/Users/davidlangley/dev/aurora/src/index.web.ts"
33-
sed -i.bak -E "s/index_bg\\.wasm/index_bg.wasm?url/" "$INDEX_FILE"
43+
echo "==> Step 10: Fixing index.web.ts import..."
44+
INDEX_FILE="src/index.web.ts"
45+
if [ -f "$INDEX_FILE" ]; then
46+
sed -i.bak -E "s/index_bg\\.wasm/index_bg.wasm?url/" "$INDEX_FILE"
47+
echo " ✓ Import fixed"
48+
else
49+
echo "$INDEX_FILE not found, skipping import fix"
50+
fi
3451

35-
echo "==> Step 10: Optimizing wasm binary with wasm-opt..."
36-
WASM_FILE="/Users/davidlangley/dev/aurora/src/generated/wasm-bindgen/index_bg.wasm"
52+
echo "==> Step 11: Optimizing wasm binary with wasm-opt..."
53+
WASM_FILE="src/generated/wasm-bindgen/index_bg.wasm"
3754
if [ -f "$WASM_FILE" ]; then
3855
echo " Optimizing $WASM_FILE (this may take a few minutes)..."
3956
wasm-opt -Oz "$WASM_FILE" -o "${WASM_FILE}.tmp" && mv "${WASM_FILE}.tmp" "$WASM_FILE"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/Cargo.toml b/Cargo.toml
2+
index 16a3f409c..eee32bb2d 100644
3+
--- a/Cargo.toml
4+
+++ b/Cargo.toml
5+
@@ -105,8 +105,8 @@ tracing-appender = "0.2.3"
6+
tracing-core = "0.1.34"
7+
tracing-subscriber = "0.3.20"
8+
unicode-normalization = "0.1.25"
9+
-uniffi = { version = "0.30.0" }
10+
-uniffi_bindgen = { version = "0.30.0" }
11+
+uniffi = { version = "=0.29.4" }
12+
+uniffi_bindgen = { version = "=0.29.4" }
13+
url = "2.5.7"
14+
uuid = "1.18.1"
15+
vergen-gitcl = "1.0.8"

patches/0001-Fix-uniffi-and-wasm-build.patch

Lines changed: 0 additions & 13 deletions
This file was deleted.

patches/0001-Fix-wasm-default-features.patch

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)