feat: remove the need of an external JS runtime for processing grammars
This commit is contained in:
parent
7ba7c4a8ce
commit
eedbec8f24
8 changed files with 760 additions and 15 deletions
|
|
@ -30,7 +30,9 @@ name = "benchmark"
|
|||
harness = false
|
||||
|
||||
[features]
|
||||
default = ["qjs-rt"]
|
||||
wasm = ["tree-sitter/wasm", "tree-sitter-loader/wasm"]
|
||||
qjs-rt = ["tree-sitter-generate/qjs-rt"]
|
||||
|
||||
[dependencies]
|
||||
ansi_colours.workspace = true
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
src,
|
||||
rustPlatform,
|
||||
version,
|
||||
clang,
|
||||
libclang,
|
||||
cmake,
|
||||
pkg-config,
|
||||
nodejs_22,
|
||||
|
|
@ -21,6 +23,7 @@ rustPlatform.buildRustPackage {
|
|||
cargoBuildFlags = [ "--all-features" ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
clang
|
||||
cmake
|
||||
pkg-config
|
||||
nodejs_22
|
||||
|
|
@ -29,6 +32,8 @@ rustPlatform.buildRustPackage {
|
|||
|
||||
cargoLock.lockFile = ../../Cargo.lock;
|
||||
|
||||
env.LIBCLANG_PATH = "${libclang.lib}/lib";
|
||||
|
||||
preBuild = ''
|
||||
rm -rf test/fixtures
|
||||
mkdir -p test/fixtures
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ struct Generate {
|
|||
#[arg(long)]
|
||||
pub json: bool,
|
||||
/// The name or path of the JavaScript runtime to use for generating parsers
|
||||
#[cfg(not(feature = "qjs-rt"))]
|
||||
#[arg(
|
||||
long,
|
||||
value_name = "EXECUTABLE",
|
||||
|
|
@ -150,6 +151,17 @@ struct Generate {
|
|||
default_value = "node"
|
||||
)]
|
||||
pub js_runtime: Option<String>,
|
||||
|
||||
#[cfg(feature = "qjs-rt")]
|
||||
#[arg(
|
||||
long,
|
||||
value_name = "EXECUTABLE",
|
||||
env = "TREE_SITTER_JS_RUNTIME",
|
||||
default_value = "node"
|
||||
)]
|
||||
/// The name or path of the JavaScript runtime to use for generating parsers, specify `native`
|
||||
/// to use the native `QuickJS` runtime
|
||||
pub js_runtime: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
|
|
@ -868,6 +880,7 @@ impl Generate {
|
|||
// TODO: migrate to `warn!` once https://github.com/tree-sitter/tree-sitter/pull/4604 is merged
|
||||
eprintln!("Warning: --build is deprecated, use --stage=lib instead");
|
||||
}
|
||||
|
||||
if let Err(err) = tree_sitter_generate::generate_parser_in_directory(
|
||||
current_dir,
|
||||
self.output.as_deref(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue