#!/usr/bin/env python3 """Generate the wasm lazy-asset manifest. The wasm build runs the engine on a worker, where synchronous XHR is legal, so assets are registered with ``FS.createLazyFile`` instead of being preloaded: the browser fetches each file only when the engine first opens it. This script lists every file under the assets root (as POSIX-relative paths) as ``{"files": [...]}``; CMake preloads the manifest to ``/assets.manifest.json``. scripts/make_web_manifest.py --root /path/to/assets --out assets.manifest.json Serve the tree at ``/assets`` (or use ``serve.py --assets``). """ import argparse import json import os import sys def main() -> int: parser = argparse.ArgumentParser(description="Generate the OpenRA3 wasm asset manifest") parser.add_argument("--root", required=True, help="assets root to enumerate") parser.add_argument("--out", required=True, help="manifest JSON to write") args = parser.parse_args() if not os.path.isdir(args.root): print(f"root not found: {args.root}", file=sys.stderr) return 1 files = [] for dirpath, dirnames, filenames in os.walk(args.root): dirnames.sort() for name in sorted(filenames): rel = os.path.relpath(os.path.join(dirpath, name), args.root).replace(os.sep, "/") files.append(rel) with open(args.out, "w", encoding="utf-8") as handle: json.dump({"files": files}, handle, separators=(",", ":")) handle.write("\n") print(f"wrote {args.out} ({len(files)} files)") return 0 if __name__ == "__main__": raise SystemExit(main())