summaryrefslogtreecommitdiff
path: root/build.rs
blob: 1d7729e0a773bf7abe51ac81d523f2c227fae759 (plain)
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
use glob::glob;
use std::path::Path;

fn main() {
    if let Err(err) = real_main() {
        eprintln!("ERROR: {}", err);
        std::process::exit(1);
    }
}

fn real_main() -> anyhow::Result<()> {
    println!("cargo:rerun-if-env-changed=DEB_BUILD_OPTIONS");
    let subplots = glob("[a-z]*.md").expect("failed to find subplots");
    let tests = Path::new("tests");
    for entry in subplots {
        let entry = entry?;
        let mut inc = tests.join(&entry);
        inc.set_extension("rs");
        if !inc.exists() {
            panic!("missing include file: {}", inc.display());
        }
        println!("cargo:rerun-if-changed={}", inc.display());
        subplot_build::codegen(Path::new(&entry))?;
    }
    Ok(())
}