4.1 KiB
Building the OneCAD Draft wasm bundle (static/onecaddraft)
The complete source state of this repository (rebrand + Odoo glue + Rust bridge) is ready to build. The wasm compile of the app crate (640k lines of Rust across 789 files) needs ~4.5 GB RAM for rustc alone — it OOM-kills in a 4 GB cgroup (verified twice with a memory monitor: rustc peaks at ~3.7 GB and grows past the ceiling during metadata encoding). Any machine with 8 GB+ free RAM and ~3 GB free disk completes it.
Build on a roomy machine (the one path that works end-to-end)
# 0) deps: rustup target add wasm32-unknown-unknown; cargo install --locked trunk
# wasm-bindgen-cli MUST match Cargo.lock (grep wasm-bindgen Cargo.lock)
# 1) OPTIONAL (recommended for production quality): restore opt level
# In Cargo.toml [profile.release] remove the opt-level = 0 line added for
# the constrained sandbox build. Upstream default (opt 3) is best for CAD.
# 2) build (trunk reads Trunk.toml: target=web-app.html, dist=dist/app,
# and runs the [[hooks]] post_build script that builds + wasm-binds
# the ocs_web_worker cdylib automatically)
trunk build --release
# 3) assemble + deploy + version lockstep (compiles web/odoo/*.ts with
# esbuild, strips sw.js/app.webmanifest, injects the odoo boot snippet,
# deploys to core-components/one_cad_draft/static/onecaddraft/)
python3 scripts/assemble_onecaddraft_dist.py # on the one-os-dev sandbox
# 4) install/upgrade the module
python3 scripts/onecaddraft-install-rpc.py # XML-RPC 127.0.0.1:18070 db=oneos
assemble_onecaddraft_dist.py gates: REQUIRED index.html,
OpenCADStudio.js, OpenCADStudio_bg.wasm, worker_pkg/ocs_web_worker.js,
worker_pkg/ocs_web_worker_bg.wasm, ocs-parse-worker.js, ocs-control.js,
locale-labels.json, non-empty fonts/; FORBIDDEN sw.js,
app.webmanifest (stripped with a loud log); no absolute /app/-prefixed
asset refs; version lockstep across bundleVersion, __manifest__.py and
the glue ?v= literals.
Sandbox lessons that cost us hours (do not re-learn)
?v=bump per build. Odoo serves statics with 7-day max-age; the assembler bumps everything in lockstep. Hard-refresh the browser once.- wasm-bindgen stack OOM when the Odoo stack is up:
oneos-dev downbefore bindgen,upafter (the assembler does not build, so this only matters for manual bindgen runs). - NEVER
wasm-tools strip -a(destroys__wasm_bindgen_unstable). Usewasm-opt --strip-dwarfthen-O1/-O2if hand-optimizing; trunk already runs the wasm-opt pass requested in the HTML tag. - Overlay rootfs: only runtime-layer deletions free space; build
scratch must be deleted eagerly (
target/release/depsre-fills on resume — deleting it buys nothing net). NO_COLOR=1breaks trunk's clap parser (--no-colorexpects true/false): run trunk withenv -u NO_COLOR.cargo checkcreates a full second (dev-profile) tree — on a constrained disk it IS the disk-full event. Don't check; build.- Orphan sweep: profile-era changes leave stale-hash artifacts forever;
scripts/prune-orphans.py(in the one-os-dev sandbox) reclaims them. - Background processes die between tool calls in the z.ai sandbox — run long builds in ≤9-minute foreground chunks; cargo resumes incrementally.
What is already wired (no further source work needed)
web/odoo/{index.ts,bridge.ts,explorer.js}— the Documents glue (save air-gap viawindow.openCadStudioSaveFile, deep-link opens viawasmBindings.ocs_web_drop_file, explorer dialogs, bind storage).src/odoo_bridge.rs— Rust bridge:File > Openin the embedded shell dispatchesonecaddraft:host-request {method:"odoo.pickOpen"}and drains completions inMessage::PollWebControl(50 ms tick) intoopen_web_bytes. Never toucheswindow.onecaddraftHostReady.src/app/update/file.rs(intercept) +src/app/update/mod.rs(drain) +src/lib.rs(module decl) +Cargo.toml(CustomEvent features).core-components/one_cad_draft/in one-os-dev: the 5-file addon (storage seq 52, menu seq 37, extensions dxf/dwg, fileExtension .dxf).