From b157c5a8a4472cff68de3a9be66e220dc4b80a9f Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Mon, 21 Feb 2022 06:39:23 -0600 Subject: fetch and compile tree-sitter grammars in helix-term build This restores much of the behavior that existed before this PR: helix will build the grammars when compiling. The difference is that now fetching is also done during the build phase and is done much more quickly - both shallow and in parallel. --- helix-term/Cargo.toml | 7 +++---- helix-term/build.rs | 8 ++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'helix-term') diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml index 86d72561..48365743 100644 --- a/helix-term/Cargo.toml +++ b/helix-term/Cargo.toml @@ -67,9 +67,8 @@ grep-searcher = "0.1.8" # Remove once retain_mut lands in stable rust retain_mut = "0.1.7" -# compiling grammars -cc = { version = "1" } -threadpool = { version = "1.0" } - [target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100 signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] } + +[build-dependencies] +helix-loader = { version = "0.6", path = "../helix-loader" } diff --git a/helix-term/build.rs b/helix-term/build.rs index b5d62b28..526cdc41 100644 --- a/helix-term/build.rs +++ b/helix-term/build.rs @@ -1,3 +1,4 @@ +use helix_loader::grammar::{build_grammars, fetch_grammars}; use std::borrow::Cow; use std::process::Command; @@ -14,5 +15,12 @@ fn main() { None => env!("CARGO_PKG_VERSION").into(), }; + if std::env::var("HELIX_DISABLE_AUTO_GRAMMAR_BUILD").is_err() { + fetch_grammars().expect("Failed to fetch tree-sitter grammars"); + build_grammars().expect("Failed to compile tree-sitter grammars"); + } + + println!("cargo:rerun-if-changed=../runtime/grammars/"); + println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", version); } -- cgit v1.2.3-70-g09d2