Generated files
Bimetal writes generated files only inside the hosts' projects: in <project>/<package> for Python and <project>/<name> for npm. It replaces or removes only the paths listed in [generated]. Every other file is yours.
What each package holds
| Python | Holds |
|---|---|
__init__.py |
The public API of the root, which imports the namespaces below it |
api.py |
Functions, classes and error classes, which call the native library |
models.py |
Pydantic models |
bimetal.py |
The runtime: it loads the extension, holds the contract hash the extension must match, and the helpers the other modules share |
native.pyi |
A stub for the extension |
native.abi3.so, native.pyd |
The extension, installed and not committed |
py.typed |
Says the package is typed |
<module>/ |
The same for each namespace |
| TypeScript | Holds |
|---|---|
index.js, index.d.ts |
The public API of the root |
api.js, api.d.ts |
Functions, classes and error classes |
models.js, models.d.ts |
Types and enums |
runtime.js, runtime.d.ts |
The loader and private helpers, private because package.json doesn't export them |
arrow.js |
The one module that imports apache-arrow, when the contract passes Arrow values |
native/native.js, native/native.d.ts, native/native_bg.wasm |
The Wasm module and its glue, with the Wasm backend |
native/native.node |
The addon, installed and not committed, with the Node.js backend |
<module>/ |
The same for each namespace |
Every generated text file starts with an AUTO-GENERATED BY Bimetal banner.
Ownership
Bimetal refuses bimetal.toml when a [generated] table records a project no host could have, or a file outside its project, and names every such entry.
If a new generated path would overwrite a file Bimetal doesn't own, the build stops before it changes anything, unless the file starts with Bimetal's banner or is the Wasm module, which Bimetal then adopts.
A listed file the sources no longer generate is stale, and so is every file of a host whose table is gone, or of a project that moved. check lists every one, and build deletes it if it's Bimetal's: a text file that starts with the banner, or native_bg.wasm. It keeps any other file, which [generated] then no longer lists.
The native artifacts of every platform go with the generated file they belong to: the extension with its stub, which has its name, and native.node with its runtime.js, and when a switch to the Wasm backend adds native_bg.wasm. A directory inside a project that the deletions empty goes too, even when Python's __pycache__ is left in it. The project itself stays.
How a build writes
A build checks every path it writes before it writes one. It then copies each new file whose bytes changed into place, through a temporary file beside it, so that a project on another file system works too, deletes the stale ones, and updates [generated] last. A file that didn't change keeps its modification time, so a file watcher doesn't run again for it. Native artifacts install the same way.
A build that fails or dies midway leaves some new files beside old ones. check reports them, and the next bimetal build adopts them and finishes. A build killed while it copies a file can leave that temporary file, named .bimetal- and random letters, beside it.
.bimetal/
Bimetal keeps its lock, staging directories and a record of the installed native artifacts, native.json, in .bimetal/ beside bimetal.toml. That record lets build replace an artifact that came from other sources or was changed, and holds what else this machine's last build read. The directory contains a .gitignore that ignores everything in it.
The compiled files
The Wasm module is optimized for size and has no debug name sections. Compiled packages contain no path from the machine that built them, so panic messages name the workspace's files relative to it, such as src/lib.rs:12:5.