From c6456d04b9f16ed8f5ad0f256a38218b514de5dc Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 24 Feb 2021 13:13:49 +0900 Subject: syntax: Drop the rayon dependency for threadpool. We just need a small concurrent threadpool for compilation. --- helix-syntax/Cargo.toml | 2 +- helix-syntax/build.rs | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'helix-syntax') diff --git a/helix-syntax/Cargo.toml b/helix-syntax/Cargo.toml index 86aaf360..c50e3091 100644 --- a/helix-syntax/Cargo.toml +++ b/helix-syntax/Cargo.toml @@ -11,4 +11,4 @@ tree-sitter = "0.17" [build-dependencies] cc = { version = "1", features = ["parallel"] } -rayon = { version = "1.5" } +threadpool = { version = "1.0" } diff --git a/helix-syntax/build.rs b/helix-syntax/build.rs index 627a0290..89641225 100644 --- a/helix-syntax/build.rs +++ b/helix-syntax/build.rs @@ -1,7 +1,8 @@ -use rayon::prelude::*; use std::path::PathBuf; use std::{env, fs}; +use std::sync::mpsc::channel; + fn get_opt_level() -> u32 { env::var("OPT_LEVEL").unwrap().parse::().unwrap() } @@ -115,10 +116,25 @@ fn main() { "tree-sitter-cpp".to_string(), ]; let dirs = collect_tree_sitter_dirs(ignore); - dirs.par_iter().for_each(|dir| { - let language = &dir[12..]; // skip tree-sitter- prefix - build_dir(&dir, &language); - }); + + let mut n_jobs = 0; + let pool = threadpool::Builder::new().build(); // by going through the builder, it'll use num_cpus + let (tx, rx) = channel(); + + for dir in dirs { + let tx = tx.clone(); + n_jobs += 1; + + pool.execute(move || { + let language = &dir[12..]; // skip tree-sitter- prefix + build_dir(&dir, &language); + + // report progress + tx.send(1).unwrap(); + }); + } + assert_eq!(rx.iter().take(n_jobs).fold(0, |a, b| a + b), n_jobs); + build_dir("tree-sitter-typescript/tsx", "tsx"); build_dir("tree-sitter-typescript/typescript", "typescript"); } -- cgit v1.2.3-70-g09d2