Skip to main content

Crate consortium_builder

Crate consortium_builder 

Source
Expand description

Compiles, post-processes, and stages every artifact a Consortium.toml describes.

consortium-cfg answers “what does this system look like, and is it valid?” and emits generated source. This crate answers “now actually build it”: four compilers, a post-processing step remoteproc requires, and a staging tree a packaging recipe can consume.

It stops short of deployment. Nothing here writes to a live target filesystem — the output is a local dist/ tree plus an optional BitBake hand-off.

§Layout

ModuleRole
pipelineThe end-to-end Consortium.toml → dist/ flow, stage by stage.
compileOne compiler per artifact kind, behind the Compiler trait.
progressReporting hooks the CLI uses to keep a step prompt visible.

§Fetch, then build offline

pipeline::fetch resolves the same Cargo projects the build plan does and downloads their dependencies (plus each target’s std and the frontend’s packages) up front. A subsequent run with PipelineConfig::offline passes --offline to every cargo invocation, so the build reads only local caches — useful for air-gapped hosts, reproducible CI, and container images that should not re-resolve the registry on each build.

§Check without building

pipeline::check is the pipeline’s cargo check: it validates the manifest, writes every endpoint’s generated module, and runs cargo check in each Cargo project with the same targets and injected environment a build uses — no linking, objcopy, signing, HMI build, or staging.

§The Compiler trait

Firmware, the Linux application, the OP-TEE TA, and the HMI frontend are built by very different toolchains, but callers drive them identically: each implementor owns a Configuration carrying all its parameters, a typed Error, and an Output (usually the path to the built artifact). See Compiler.

§Plan, then run

pipeline::plan resolves every stage’s inputs — paths, env vars, artifact locations — without running any build, threading the data flow between stages. pipeline::run plans, then executes.

That split is what makes the pipeline debuggable: a wrong sysroot or a missing firmware ELF surfaces as a planning failure naming the stage, rather than as a cargo error several minutes into a cross-compile.

§Compile-time configuration

Memory layout lives in generated source, not the environment: controller firmware gets its IPC region base and its [dbg] ring baked into generated init(), and the Linux application reaches the same memory through its UIO devices. What still travels as environment variables is what generated code cannot know: the on-target HMI asset paths (HmiConfig, read with option_env!), the TEE UUID, and the CSTI_* build-host directories (CstiWorkspace). Numeric values are emitted as decimal strings.

§Firmware post-processing

Linux remoteproc expects a coprocessor’s vector table in a section named .isr_vectors, but cortex-m-rt emits .vector_table. The pipeline renames it, and keeps the debug/original artifacts alongside the deployable ELF.

§Staging

The assembled tree can contain app/, firmware/, ta/, www/, dts/linux/, kernel/, boot/, and systemd/, plus a generated BitBake recipe. CLI flags can stage that tree into a recipe’s files/ directory and invoke or dry-run BitBake — the dry-run path exists for the split-machine flow, where dist/ is produced on one host and the Yocto build runs on another.

Keep the planning, compilation, staging, and external BitBake hand-off boundaries distinct when extending this crate; and prefer extending consortium-cfg lowering first, then the pipeline.

Re-exports§

pub use progress::BuildReporter;
pub use progress::BuildStep;
pub use pipeline::CargoOptions;
pub use pipeline::PipelineConfig;
pub use pipeline::PipelineError;
pub use pipeline::PipelinePlan;
pub use pipeline::run as run_pipeline;
pub use pipeline::check::CheckConfig;
pub use pipeline::check::CheckPlan;
pub use pipeline::check::run as run_check;
pub use pipeline::fetch::FetchConfig;
pub use pipeline::fetch::FetchPlan;
pub use pipeline::fetch::run as run_fetch;

Modules§

pipeline
End-to-end build pipeline: Consortium.toml → dist/.
progress
Build progress reporting hooks used by the CLI.

Structs§

ApplicationBuilder
Backward-compatible builder; delegates to ApplicationCompiler.
ApplicationCompiler
Compiler for Linux applications targeting Yocto A-cores.
ApplicationConfiguration
Build parameters for a Linux application (typically targeting a Yocto A-core).
CstiWorkspace
The build-host directories a pipeline run exposes to every endpoint cargo invocation, plus the [profile] workspace layout that decides where each endpoint crate’s target/ lives.
FirmwareBuilder
Backward-compatible builder; delegates to FirmwareCompiler.
FirmwareCompiler
Compiler for bare-metal Cortex-M firmware.
FirmwareConfiguration
Build parameters for bare-metal coprocessor firmware.
HmiCompiler
Compiler for the HMI frontend: runs the frontend build then verifies dist.
HmiConfiguration
Build parameters for the HMI frontend.
OpteeBuilder
Backward-compatible builder; delegates to OpteeCompiler.
OpteeCompiler
Compiler for OP-TEE Trusted Applications: builds the ELF then signs it.
OpteeConfiguration
All build + signing parameters for an OP-TEE Trusted Application.
OpteeEnvironment
Backward-compatible environment for OpteeBuilder.
SystemdUnitConfig
Parameters for the application’s systemd service unit.

Enums§

ApplicationCompileError
Error type for application compilation.
CortexMcuCore
Cortex-M core a firmware crate targets; selects the Rust target triple.
FirmwareCompileError
Error type for firmware compilation.
HmiBuildCommand
How the HMI frontend is built.
HmiCompileError
Error type for HMI frontend compilation.
HmiConfig
Compile-time HMI carrier the builder injects as environment variables before invoking the application cargo build. The consuming runtime crate reads them with option_env! at compile time, so the values are on-target paths resolved beneath [profile] deploy_root — the build host never dereferences them.
OpteeCompileError
Error type for OP-TEE compilation and signing.
SystemdRestartPolicy
How systemd should restart the daemon.

Constants§

OPTEE_TARGET

Traits§

Compiler
Unified async compilation trait for firmware, application, and OP-TEE targets.

Functions§

render_systemd_unit
Renders the .service unit text for config.
write_systemd_unit
Renders config and writes it to dir/<unit_name>.service, returning the written path.