feat(cli)!: add a separate build command to compile parsers
This allows users to build parsers without having to run `test` or `parse` to invoke the compilation process, and allows them to output the object file to wherever they like. The `build-wasm` command was merged into this by just specifying the `--wasm` flag.
This commit is contained in:
parent
a1c39d4760
commit
99b93d83a1
12 changed files with 249 additions and 139 deletions
|
|
@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
|
|||
use std::{env, fs};
|
||||
use tree_sitter::Language;
|
||||
use tree_sitter_highlight::HighlightConfiguration;
|
||||
use tree_sitter_loader::Loader;
|
||||
use tree_sitter_loader::{CompileConfig, Loader};
|
||||
use tree_sitter_tags::TagsConfiguration;
|
||||
|
||||
include!("./dirs.rs");
|
||||
|
|
@ -32,13 +32,10 @@ pub fn scratch_dir() -> &'static Path {
|
|||
}
|
||||
|
||||
pub fn get_language(name: &str) -> Language {
|
||||
TEST_LOADER
|
||||
.load_language_at_path(
|
||||
&GRAMMARS_DIR.join(name).join("src"),
|
||||
&[&HEADER_DIR, &GRAMMARS_DIR.join(name).join("src")],
|
||||
None,
|
||||
)
|
||||
.unwrap()
|
||||
let src_dir = GRAMMARS_DIR.join(name).join("src");
|
||||
let mut config = CompileConfig::new(&src_dir, None, None);
|
||||
config.header_paths.push(&HEADER_DIR);
|
||||
TEST_LOADER.load_language_at_path(config).unwrap()
|
||||
}
|
||||
|
||||
pub fn get_language_queries_path(language_name: &str) -> PathBuf {
|
||||
|
|
@ -141,7 +138,9 @@ pub fn get_test_language(name: &str, parser_code: &str, path: Option<&Path>) ->
|
|||
vec![parser_path]
|
||||
};
|
||||
|
||||
TEST_LOADER
|
||||
.load_language_at_path_with_name(&src_dir, &[&HEADER_DIR], name, Some(&paths_to_check))
|
||||
.unwrap()
|
||||
let mut config = CompileConfig::new(&src_dir, Some(&paths_to_check), None);
|
||||
config.header_paths = vec![&HEADER_DIR];
|
||||
config.name = name.to_string();
|
||||
|
||||
TEST_LOADER.load_language_at_path_with_name(config).unwrap()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue