@@ -7,7 +7,8 @@ use std::sync::mpsc::channel;
8fn collect_tree_sitter_dirs(ignore: &[String]) -> Vec<String> {
8fn collect_tree_sitter_dirs(ignore: &[String]) -> Vec<String> {
9 let mut dirs = Vec::new();
9 let mut dirs = Vec::new();
10+ let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("languages");
10− for entry in fs::read_dir("languages").unwrap().flatten() {
11+ for entry in fs::read_dir(path).unwrap().flatten() {
11 let path = entry.path();
12 let path = entry.path();
12 let dir = path.file_name().unwrap().to_str().unwrap().to_string();
13 let dir = path.file_name().unwrap().to_str().unwrap().to_string();
13 if !ignore.contains(&dir) {
14 if !ignore.contains(&dir) {
@@ -54,13 +55,14 @@ fn build_library(src_path: &Path, language: &str) -> Result<()> {
54 if !recompile {
55 if !recompile {
55 return Ok(());
56 return Ok(());
57−
58+ let build_dir = std::env::var("OUT_DIR").unwrap();
58 let mut config = cc::Build::new();
59 let mut config = cc::Build::new();
59 config.cpp(true).opt_level(2).cargo_metadata(false);
60 config.cpp(true).opt_level(2).cargo_metadata(false);
60 // .target(BUILD_TARGET)
61 // .target(BUILD_TARGET)
61 // .host(BUILD_TARGET);
62 // .host(BUILD_TARGET);
62 let compiler = config.get_compiler();
63 let compiler = config.get_compiler();
63 let mut command = Command::new(compiler.path());
64 let mut command = Command::new(compiler.path());
65+ command.current_dir(build_dir);
64 for (key, value) in compiler.env() {
66 for (key, value) in compiler.env() {
65 command.env(key, value);
67 command.env(key, value);
@@ -185,7 +187,10 @@ fn build_dir(dir: &str, language: &str) {
185 std::process::exit(1);
187 std::process::exit(1);
188− let path = Path::new("languages").join(dir).join("src");
190+ let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
189 build_library(&path, language).unwrap();
194 build_library(&path, language).unwrap();