#!/usr/bin/env python3 """Incrementally compile the local WebEngine and publish its integrity binding.""" import json import os from pathlib import Path import shutil import subprocess import time ROOT = Path(__file__).resolve().parents[1] def main(): nodes = sorted((ROOT / ".emsdk/node").glob("*/bin/node")) node = str(nodes[-1]) if nodes else shutil.which("node") if not node: raise RuntimeError("local Node executable missing") environment = {**os.environ, "EM_CONFIG": str(ROOT / ".emscripten-web"), "EM_LLVM_ROOT": str(ROOT / ".emsdk/upstream/bin"), "EM_BINARYEN_ROOT": str(ROOT / ".emsdk/upstream"), "EM_NODE_JS": node, "EM_LLVM_ADD_VERSION": "", "EM_CLANG_ADD_VERSION": "", } jobs = max(1, min(4, int(os.environ.get("CMAKE_BUILD_PARALLEL_LEVEL", "4")))) stages = [] for name, argv in [ ("incremental_compile", ["cmake", "--build", "build_web_blender6", "--target", "web_engine", "--parallel", str(jobs)]), ("runtime_integrity_sync", ["node", "tools/web/sync-web-engine-runtime.mjs"]), ]: start = time.monotonic() result = subprocess.run(argv, cwd=ROOT, env=environment) stages.append({"stage": name, "seconds": round(time.monotonic() - start, 6), "exitCode": result.returncode}) print(json.dumps(stages[-1]), flush=True) if result.returncode: return result.returncode if os.environ.get("WBV2_RECEIPT_DIR"): output = Path(os.environ["WBV2_RECEIPT_DIR"]) output.mkdir(parents=True, exist_ok=True) (output / "build-stages.json").write_text(json.dumps(stages, indent=2) + "\n", encoding="utf-8") return 0 if __name__ == "__main__": raise SystemExit(main())