use std::{path::PathBuf, process::Command};

fn main() {
    let design = std::env::args().nth(1).expect("you should pass one arg");
    let out = PathBuf::from("testing").join("designs");
    if !out.exists() {
        std::fs::create_dir(&out).unwrap_or_else(|_| panic!("cannot create {} dir", out.display()));
    }
    let out = std::fs::canonicalize(out).expect("canonicalize failed");
    Command::new("/home/adiallo/.local/share/coursier/bin/mill")
        .current_dir("rtl")
        .arg("ucb_tuto")
        .args([
            "--target",
            out.display().to_string().as_str(),
            design.as_str(),
        ])
        .status()
        .expect("failed to compile the rtl");
}