@@ -7,7 +7,8 @@ use std::sync::mpsc::channel;
77
88fn collect_tree_sitter_dirs(ignore: &[String]) -> Vec<String> {
99 let mut dirs = Vec::new();
10− for entry in fs::read_dir("languages").unwrap().flatten() {
10+ let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("languages");
11+ for entry in fs::read_dir(path).unwrap().flatten() {
1112 let path = entry.path();
1213 let dir = path.file_name().unwrap().to_str().unwrap().to_string();
1314 if !ignore.contains(&dir) {
@@ -54,13 +55,14 @@ fn build_library(src_path: &Path, language: &str) -> Result<()> {
5455 if !recompile {
5556 return Ok(());
5657 }
57−
58+ let build_dir = std::env::var("OUT_DIR").unwrap();
5859 let mut config = cc::Build::new();
5960 config.cpp(true).opt_level(2).cargo_metadata(false);
6061 // .target(BUILD_TARGET)
6162 // .host(BUILD_TARGET);
6263 let compiler = config.get_compiler();
6364 let mut command = Command::new(compiler.path());
65+ command.current_dir(build_dir);
6466 for (key, value) in compiler.env() {
6567 command.env(key, value);
6668 }
@@ -185,7 +187,10 @@ fn build_dir(dir: &str, language: &str) {
185187 std::process::exit(1);
186188 }
187189
188− let path = Path::new("languages").join(dir).join("src");
190+ let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
191+ .join("languages")
192+ .join(dir)
193+ .join("src");
189194 build_library(&path, language).unwrap();
190195}
191196