Skip to main content

autograde_rs/
build.rs

1use std::str::from_utf8;
2
3use anyhow::{bail, Context};
4use serde::Deserialize;
5use tokio::process::Command;
6
7#[derive(Deserialize, Debug)]
8pub enum BuildSystem {
9    Make,
10    Digital,
11    Cargo,
12}
13
14pub async fn make() -> anyhow::Result<()> {
15    // TODO just, cargo, etc
16    let make_output = Command::new("make").output().await.with_context(|| {
17        "Could not spawn a child proccess or get its output!
18        Tried to call: make"
19            .to_string()
20    })?;
21
22    if !make_output.status.success() {
23        eprintln!("Failed to make!");
24        let make_stdout = from_utf8(&make_output.stdout)?;
25        let make_stderr = from_utf8(&make_output.stderr)?;
26        println!("{}", make_stdout);
27        eprintln!("{}", make_stderr);
28
29        bail!("Make failed with {}", make_output.status)
30    }
31
32    Ok(())
33}