Skip to content

Commit

Permalink
Merge pull request #2994 from itowlson/build-multi-step-feedback
Browse files Browse the repository at this point in the history
Clearer progress info for multi-command builds
  • Loading branch information
itowlson authored Jan 27, 2025
2 parents c048e12 + 8d54391 commit 1239a21
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
27 changes: 25 additions & 2 deletions crates/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,31 @@ fn build_components(
fn build_component(build_info: ComponentBuildInfo, app_dir: &Path) -> Result<()> {
match build_info.build {
Some(b) => {
for command in b.commands() {
terminal::step!("Building", "component {} with `{}`", build_info.id, command);
let command_count = b.commands().len();

if command_count > 1 {
terminal::step!(
"Building",
"component {} ({} commands)",
build_info.id,
command_count
);
}

for (index, command) in b.commands().enumerate() {
if command_count > 1 {
terminal::step!(
"Running build step",
"{}/{} for component {} with '{}'",
index + 1,
command_count,
build_info.id,
command
);
} else {
terminal::step!("Building", "component {} with `{}`", build_info.id, command);
}

let workdir = construct_workdir(app_dir, b.workdir.as_ref())?;
if b.workdir.is_some() {
println!("Working directory: {}", quoted_path(&workdir));
Expand Down
2 changes: 1 addition & 1 deletion crates/manifest/src/schema/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub struct ComponentBuildConfig {

impl ComponentBuildConfig {
/// The commands to execute for the build
pub fn commands(&self) -> impl Iterator<Item = &String> {
pub fn commands(&self) -> impl ExactSizeIterator<Item = &String> {
let as_vec = match &self.command {
Commands::Single(cmd) => vec![cmd],
Commands::Multiple(cmds) => cmds.iter().collect(),
Expand Down

0 comments on commit 1239a21

Please sign in to comment.