aboutsummaryrefslogtreecommitdiff
path: root/mingling_ci/src/task/cmd_build.rs
blob: 44be59205c2478291d078002e4a6f9cee8b8f171 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use std::ffi::OsString;
use std::path::Path;

use mingling::{
    Grouped, Routable,
    macros::{buffer, command, renderer},
    res::ResExitCode,
};

use crate::Next;
use crate::res::Manifests;
use crate::task::run::run_parallel_checks;

#[command(node = "build-all")]
pub async fn build_all(manifests: &Manifests) -> Next {
    let fail_count = run_parallel_checks("Build-All", "Building", build_args, manifests).await;
    ResultBuildAll { fail_count }.to_chain()
}

/// `cargo build --manifest-path <path>`
fn build_args(path: &Path) -> Vec<OsString> {
    vec![
        "build".into(),
        "--manifest-path".into(),
        path.as_os_str().to_os_string(),
    ]
}

/// Number of packages that failed to build.
#[derive(Grouped)]
pub struct ResultBuildAll {
    pub fail_count: usize,
}

/// Silently sets a non-zero exit code when any build failed.
#[renderer(buffer)]
pub fn render_build_all(r: ResultBuildAll, exit_code: &mut ResExitCode) {
    if r.fail_count > 0 {
        exit_code.exit_code = 1;
    }
}