kiln_build/lib.rs
1// `BuildError` carries paths and captured stderr; surfacing them is the whole
2// point of this crate. Suppress the lint here for the same reason we did in
3// `slang-rs`.
4#![allow(clippy::result_large_err)]
5//! Build pipeline and simulator backends for `kiln`.
6//!
7//! The crate is organised so the high-level `kiln build` flow is a small
8//! sequence of steps:
9//!
10//! 1. [`SourceSet::resolve`] expands the manifest's globs into absolute
11//! source paths.
12//! 2. [`BuildPlan::new`] turns a manifest + source set + profile into an
13//! invocation plan with a deterministic content hash.
14//! 3. A backend (today: [`backend::verilator`]) compiles that plan and
15//! parses the simulator's output into [`Diagnostic`]s.
16//!
17//! This crate is intentionally simulator-agnostic at the type level;
18//! M5 will plug a Cocotb backend onto the same plan. M3 will reuse
19//! [`Diagnostic`] for the slang-driven `kiln check` rendering path.
20
21pub mod backend;
22pub mod cache;
23pub mod diagnostic;
24pub mod plan;
25pub mod render;
26pub mod source_set;
27
28pub use backend::BackendError;
29pub use cache::{cache_dir, BuildCacheKey};
30pub use diagnostic::{BuildDiagnostic, Severity};
31pub use plan::{aggregate_blackbox_modules, BuildPlan, Profile};
32pub use source_set::{SourceSet, SourceSetError};
33
34use thiserror::Error;
35
36#[derive(Debug, Error)]
37pub enum BuildError {
38 #[error(transparent)]
39 SourceSet(#[from] SourceSetError),
40
41 #[error(transparent)]
42 Backend(#[from] BackendError),
43
44 #[error("I/O error at {path}: {source}")]
45 Io {
46 path: std::path::PathBuf,
47 #[source]
48 source: std::io::Error,
49 },
50}