#!/usr/bin/env python3 # file: scripts/build_reflex_tauri_wasm.py # version: 1 """Build the Reflex WASM adapter and generate browser bindings for the local Tauri frontend.""" from __future__ import annotations import pathlib import subprocess import sys def main() -> int: """Build the WASM library and run wasm-bindgen into the committed Tauri frontend directory.""" root = pathlib.Path(__file__).resolve().parent.parent target_dir = root.parent / "builds" / "sasedev-games" / "target" wasm_path = target_dir / "wasm32-unknown-unknown" / "debug" / "game_reflex_poc_tauri.wasm" output_dir = root / "Tauri" / "game-reflex-poc" / "frontend" build = subprocess.run( ["cargo", "build", "-p", "game-reflex-poc-tauri", "--lib", "--target", "wasm32-unknown-unknown"], cwd=root, check=False, ) if build.returncode != 0: return build.returncode if not wasm_path.is_file(): print(f"WASM artifact not found: {wasm_path}", file=sys.stderr) return 2 bindings = subprocess.run( [ "wasm-bindgen", str(wasm_path), "--target", "web", "--out-dir", str(output_dir), "--out-name", "game_reflex_poc_tauri", "--no-typescript", ], cwd=root, check=False, ) if bindings.returncode != 0: return bindings.returncode print(f"Reflex Tauri WASM frontend generated in {output_dir}") return 0 if __name__ == "__main__": raise SystemExit(main())