Skip to main content

consortium_builder/
progress.rs

1// Copyright 2026 Ethan Wu
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// SPDX-License-Identifier: Apache-2.0
16
17//! Build progress reporting hooks used by the CLI.
18//!
19//! The builder crate keeps these hooks deliberately small: library callers can
20//! ignore them and retain inherited subprocess output, while the CLI can pass a
21//! reporter that keeps a persistent step prompt under cargo/vp/bitbake output.
22
23/// A single executable build step.
24#[derive(Clone, Copy, Debug)]
25pub struct BuildStep<'a> {
26    /// One-based position of this step in the executable plan.
27    pub index: usize,
28    /// Total executable steps in this run.
29    pub total: usize,
30    /// Short stage name.
31    pub name: &'a str,
32    /// Optional target or artifact detail.
33    pub detail: Option<&'a str>,
34}
35
36/// Receives progress events and streamed child-process output.
37pub trait BuildReporter: Send + Sync {
38    /// A step is about to run.
39    fn step_started(&self, step: BuildStep<'_>);
40
41    /// A step completed successfully.
42    fn step_succeeded(&self, step: BuildStep<'_>);
43
44    /// A step failed.
45    fn step_failed(&self, step: BuildStep<'_>);
46
47    /// Output emitted by a subprocess belonging to the current step.
48    fn command_output(&self, output: &str);
49}