Skip to main content

Crate flow_toolkit_rust

Crate flow_toolkit_rust 

Source
Expand description

Building a Rust library’s one launcher, and reading its contract modules from it (abi.md, Generated contracts and Toolkits).

A library is a directory holding the Cargo.toml of its crate, a package and not a virtual workspace. Its flow.toml runs this toolkit as an ordinary [process] library:

[process]
command = "flow-toolkit-rust serve"
extract = "flow-toolkit-rust extract"

extract --library ROOT --out OUT --depfile FILE builds the crate’s launcher in Cargo’s release profile, compiled incrementally unless the crate’s workspace sets incremental for it, when the crate’s inputs changed, writes each contract module as OUT/<module path>.flow (abi.md, Extracting a contract) and lists in FILE every file it read and every directory it scanned, one absolute path to a line. serve --contract FILE, started in the library’s root, builds the launcher the same way when it is missing or stale and then becomes it, serving the host’s --contract file. export --library ROOT --out DIR builds the launcher optimized and copies it to DIR/<name>, <name> being the library directory’s name (<name>.exe on Windows): a standalone program a release bundle names as its library’s [process] command. new DIR writes a library to start from.

Nothing is written into a library’s tree. Each library’s preparation lives in the toolkit’s cache directory (cache_home), under flow-toolkit-rust/libraries/<digest>, the digest being that of the library root’s canonical path, and every launcher compiles in the one Cargo target directory flow-toolkit-rust/target beside them, so the libraries share their compiled dependencies. Cargo finds the crate’s workspace as cargo build in the library root would, and resolves it --locked against that workspace’s Cargo.lock, so a fetched tree builds exactly as its commit holds it. The launcher crate the toolkit generates declares a [workspace] of its own, so it never joins an enclosing one, and depends on the flow-toolkit crate the library itself resolves, or on the toolkit installed around this executable when the library resolves none.

A launcher’s inputs are what Cargo compiled for it, as the dependency information it writes beside the launcher names them (with the files a build script names by rerun-if-changed), together with the Cargo manifests, locks and toolchain files that select them up to the workspace’s root. Files of the library and of its local path dependencies are named by their paths relative to the library root; a test, a benchmark or a document no build compiles is none of them. Registry and Git dependencies are pinned by Cargo.lock. Environment variables count by the CARGO_, RUST, CC and CXX prefixes, in the fingerprint only; another variable a build script names by rerun-if-env-changed, or a source reads with env!, is not tracked.

Structs§

Exported
A crate’s exported launcher and contract, copied out of its cache.
Place
A place in a file: the file, and the line and column where known.

Enums§

CargoOutput
What Cargo reported that the toolkit does not read.
CargoStep
The Cargo command that failed.
LibraryProblem
What is wrong with a file of the library, or of its build.
MetadataKey
A key of a row of cargo metadata the toolkit reads.
NewError
new refuses the directory it was given.
PrepareError
Why the command failed. Every refusal, a missing Rust toolchain included, exits with status 2 and says why on standard error.

Constants§

COMMAND
The toolkit’s command: the program a library’s flow.toml names, and the name of the toolkit’s directory in the platform’s cache.

Functions§

cache_home
The directory the toolkit keeps its cache under: XDG_CACHE_HOME when it is set to an absolute path, on every platform, and otherwise the platform’s own cache directory, ~/Library/Caches on macOS, %LOCALAPPDATA% on Windows and ~/.cache elsewhere. The toolkit’s own directory is COMMAND inside it.
export
Builds the crate at library optimized, and exports its launcher and contract modules, keeping its preparation in the toolkit’s cache under cache_home.
main
Runs the command arguments give, the program’s own name not among them (flow_toolkit::cli).