boxddd-sys - Low-level FFI for Box3D
boxddd-sys builds the vendored Box3D C sources from third-party/box3d and exposes the raw C API in boxddd_sys::ffi.
High-level, safe Rust wrappers live in the companion boxddd crate.
Build
- Default: builds vendored Box3D C sources with
cc. - External link: disable default features to skip vendored C compilation and link an external
box3dlibrary instead. - Bindings: uses checked-in pregenerated bindings so normal builds do not require LLVM or libclang.
- Refresh: enable the
bindgenfeature and setBOXDDD_SYS_FORCE_BINDGEN=1. - Docs.rs/offline docs: uses pregenerated bindings and skips native C compilation.
- WASM compile-only:
wasm32-unknown-unknownskips C compilation by default. - WASM runtime smoke:
wasm32-wasip1builds vendored C sources whenWASI_SYSROOTorWASI_SDK_PATHpoints at WASI SDK. - WASM provider:
BOXDDD_SYS_WASM_MODE=providergenerates import bindings for modulebox3d-sys-v0;xtask provider-smokebuilds an Emscripten provider and runs the shared-memory smoke.
For normal users, cargo build compiles the vendored C sources for the current target and links the resulting static library into the Rust crate. This requires the platform C compiler that Rust's cc crate can find, but it does not require CMake, LLVM, libclang, or running bindgen.
Features
build-from-source: compile vendored Box3D C sources. Enabled by default.bindgen: enable bindgen-based binding refresh.double-precision: build Box3D withBOX3D_DOUBLE_PRECISIONand use matching pregenerated bindings.disable-simd: defineBOX3D_DISABLE_SIMD.validate: defineBOX3D_VALIDATE.
Environment
BOXDDD_SYS_FORCE_BINDGEN=1: regenerate bindings into Cargo'sOUT_DIR; requires--features bindgen.BOXDDD_SYS_SKIP_CC=1: skip native C compilation for check-only workflows.BOXDDD_SYS_WASM_MODE: override wasm mode. Accepted values arecompile-only,source, andprovider.BOXDDD_SYS_SKIP_CC=1is rejected withBOXDDD_SYS_WASM_MODE=sourcebecause source mode is the runtime-capable WASM path.BOXDDD_SYS_LINK_LIB: external library name used whenbuild-from-sourceis disabled. Defaults tobox3d.BOXDDD_SYS_LINK_SEARCH: optional native library search directory used whenbuild-from-sourceis disabled.WASI_SYSROOT: WASI libc sysroot used bywasm32-wasip1source builds.WASI_SDK_PATH: WASI SDK root. IfWASI_SYSROOTis unset,build.rsuses$WASI_SDK_PATH/share/wasi-sysroot.DOCS_RS=1or--cfg docsrs: skip native C compilation for documentation.
WASM Commands
Compile-only browser target:
Provider import-mode check:
BOXDDD_SYS_WASM_MODE=provider
Browser-style provider smoke:
# Full smoke requires Emscripten SDK (`emcc`) on PATH or EMSDK set.
The provider smoke verifies shared memory and imported Box3D symbols without
cross-module callback function pointers. Callback-heavy APIs need a dedicated
shared-table or dynamic-linking path before browser provider mode can claim
them; the safe wrapper currently reports them as Error::UnsupportedOnWasm.
C-backed WASI source build:
Notes
The pregenerated bindings are ABI-mode specific. If double-precision is enabled, the crate uses bindings_pregenerated_double.rs; otherwise it uses bindings_pregenerated.rs.
License
This crate is licensed as MIT OR Apache-2.0. Vendored Box3D is MIT-licensed.