niso-compose
Generated from crates/niso-compose/CONTRACT.md when the site was built at 7aa23e2.
Purpose
Section titled “Purpose”The build-time helper that composes niso’s C runtime header (niso_runtime.h) and JS glue (glue.js) from sections that each belong to one crate (architecture.md 6 and 7, migration step 6). It has no niso dependency and runs only in build scripts and xtask.
Public surface
Section titled “Public surface”MANIFEST: crates/niso-compose/sections.txt, which names each section of the two files, its owner crate and its anchor, and each file’s composition order.blocks(manifest)parses a manifest;block(name)is a block ofMANIFEST.Block::split(text)cuts a monolith into its sections;Block::sourceis where a section lives after the cut-over;Block::read(root)reads the sections from there.Split::composeandSplit::ordered: the composed file and its order.compose(name, root), for build scripts: the composed file, from the sections’ files (or from the monolith on a branch that predates the cut-over); it prints thecargo::rerun-if-changedlines for what it read.same_lines(a, b): whether two texts have the same lines in any order.
Guarantees
Section titled “Guarantees”- Sections cover the monolith: every line is in exactly one section, so concatenating the sections in the monolith’s order gives the monolith byte for byte, and a composition in another order has the same lines (unit tests; over the real section files, one checks that they still cut at their anchors into themselves, which resplit relies on).
- A section starts at its anchor, the start of a line at column 0 after the previous section’s anchor, or at the comment right above that line. A missing anchor is an error that names the manifest line; nothing is assigned silently.
- Composition order is the manifest’s:
order filekeeps the monolith’s; a list of owners giveshead, each owner’s sections in that order (each owner’s in the monolith’s order), thentail. - After the cut-over a section lives in its owner’s tree
(
crates/<owner>/include/<section>.horglue/<section>.js), in niso-core’s while the owner crate does not exist, in bindings/js/glue for the glue core, and in crates/niso-compose/frame for the composition’s own sections. A missing file is an error naming the section.
May assume from dependencies
Section titled “May assume from dependencies”None; it uses std only.
Differences from architecture.md 6
Section titled “Differences from architecture.md 6”The architecture’s composition reads each crate’s fragments from Cargo
links metadata (DEP_*). Until a crate brings its own IDL (step 6c) and
its glue is a module with install(ctx), the manifest stands in for that
metadata: it is the one list of sections and owners, and the glue keeps the
monolith’s order because its statements run in order.
Standalone use
Section titled “Standalone use”niso_compose::compose("header", &workspace_root) in a build script;
cargo xtask split to see the sections and check them.