aboutsummaryrefslogtreecommitdiff
path: root/helix-syntax/build.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-02-24 04:13:49 +0000
committerBlaž Hrastnik2021-02-24 04:17:10 +0000
commitc6456d04b9f16ed8f5ad0f256a38218b514de5dc (patch)
tree63a43d8a0b01cdedb0f51e2be0e9b4816cae092e /helix-syntax/build.rs
parent41c0d5828fe301edf3bbc1dbd8fad7adf507e03e (diff)
syntax: Drop the rayon dependency for threadpool.
We just need a small concurrent threadpool for compilation.
Diffstat (limited to 'helix-syntax/build.rs')
-rw-r--r--helix-syntax/build.rs26
1 files changed, 21 insertions, 5 deletions
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::<u32>().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");
}