use std::path::Path;
use std::{env, fs};
fn main() {
let source_path = Path::new("tree-sitter");
let build_path = Path::new(&env::var_os("OUT_DIR").unwrap()).join("tree-sitter");
if !build_path.exists() {
fs::create_dir(&build_path).unwrap();
}
fs::copy(
source_path.join("grammar.js"),
build_path.join("grammar.js"),
)
.unwrap();
tree_sitter_generate::generate_parser_in_directory(&build_path, None, 14, None, None).unwrap();
let src_path = build_path.join("src");
cc::Build::new()
.include(&src_path)
.file(src_path.join("parser.c"))
.compile("parser");
println!(
"cargo:rerun-if-changed={}",
source_path.join("grammar.js").to_str().unwrap()
);
}