about summary refs log tree commit diff
path: root/kittybox-rs/build.rs
blob: 3d4c62b0f2cb1919f7ca6cf6a89682a793a565b9 (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
fn main() {
    use std::env;
    let out_dir = env::var("OUT_DIR").unwrap();
    println!("cargo:rerun-if-changed=javascript/");

    if let Ok(exit) = std::process::Command::new("tsc")
        .arg("--outDir")
        .arg(std::path::Path::new(&out_dir).join("kittybox_js"))
        .current_dir("javascript")
        .spawn()
        .unwrap()
        .wait()
    {
        if !exit.success() {
            std::process::exit(exit.code().unwrap_or(1))
        }
    }

    println!("cargo:rerun-if-changed=companion-lite/");
    let companion_out = std::path::Path::new(&out_dir).join("companion");

    if let Ok(exit) = std::process::Command::new("tsc")
        .arg("--outDir")
        .arg(companion_out.as_os_str())
        .current_dir("companion-lite")
        .spawn()
        .unwrap()
        .wait()
    {
        if !exit.success() {
            std::process::exit(exit.code().unwrap_or(1))
        }
    }
    let companion_in = std::path::Path::new("companion-lite");
    for file in ["index.html", "style.css"] {
        std::fs::copy(
            companion_in.join(file),
            &companion_out.join(file)
        ).unwrap();
    }
}