From c8dc9b64dd0f6726cd1d36a61c563212721ef249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Mon, 12 Jul 2021 00:44:14 +0900 Subject: [PATCH] windows: Try building inside OUT_DIR? --- helix-syntax/build.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/helix-syntax/build.rs b/helix-syntax/build.rs index 02a5bf49..2882f513 100644 --- a/helix-syntax/build.rs +++ b/helix-syntax/build.rs @@ -7,7 +7,8 @@ use std::sync::mpsc::channel; fn collect_tree_sitter_dirs(ignore: &[String]) -> Vec { let mut dirs = Vec::new(); - for entry in fs::read_dir("languages").unwrap().flatten() { + let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("languages"); + for entry in fs::read_dir(path).unwrap().flatten() { let path = entry.path(); let dir = path.file_name().unwrap().to_str().unwrap().to_string(); if !ignore.contains(&dir) { @@ -54,13 +55,14 @@ fn build_library(src_path: &Path, language: &str) -> Result<()> { if !recompile { return Ok(()); } - + let build_dir = std::env::var("OUT_DIR").unwrap(); let mut config = cc::Build::new(); config.cpp(true).opt_level(2).cargo_metadata(false); // .target(BUILD_TARGET) // .host(BUILD_TARGET); let compiler = config.get_compiler(); let mut command = Command::new(compiler.path()); + command.current_dir(build_dir); for (key, value) in compiler.env() { command.env(key, value); } @@ -185,7 +187,10 @@ fn build_dir(dir: &str, language: &str) { std::process::exit(1); } - let path = Path::new("languages").join(dir).join("src"); + let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("languages") + .join(dir) + .join("src"); build_library(&path, language).unwrap(); }