aboutsummaryrefslogtreecommitdiff
path: root/build.rs
blob: fbb4adee84852a479bf41080b4ca0b67d880e87b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use std::{
    env::var, fs::{read, write}, io::Write, path::{Path, PathBuf}, process::{
        Command,
        Stdio,
    }
};

fn main() {
    println!("test");
    println!("cargo::rerun-if-changed=nvim-treesitter/lua/nvim-treesitter/parsers.lua");
    println!("cargo::rerun-if-changed=generate_parsers.lua");
    let mut child = Command::new("lua").arg("generate_parsers.lua").stdin(Stdio::piped()).stdout(Stdio::piped()).spawn().expect("Failed to spawn process");

    let mut stdin = child.stdin.take().expect("Failed to open stdin");
    std::thread::spawn(move || {
        stdin.write_all(read(Path::new("nvim-treesitter/lua/nvim-treesitter/parsers.lua")).expect("Failed to create parsers path").as_ref()).expect("Failed to write to stdin");
    }).join().unwrap();

    let output = child.wait_with_output().expect("Failed to read stdout");
    write(PathBuf::from(format!("{}/_parsers.rs", var("OUT_DIR").unwrap())), output.stdout).unwrap();
}