tree-sitter-wasm-build-tool
A crate to easily allow tree-sitter parsers to compile to Rust's
wasm32-unknown-unknown
target.
Currently, this only works with parsers that do not make use of an external C++ scanner.
It is meant to be used in build scripts, typically only if some
wasm
or
c2rust
feature is enabled.
For example:
```rust,norun let srcdir = std::path::Path::new("src"); let mut cconfig = cc::Build::new(); cconfig.include(srcdir); cconfig .flag("-Wno-unused-parameter") .flag("-Wno-unused-but-set-variable") .flag("-Wno-trigraphs"); let parserpath = srcdir.join("parser.c"); cconfig.file(&parserpath);
treesitterwasmbuildtool::addwasmheaders(&mut c_config).unwrap();
cconfig.compile("parser"); println!("cargo:rerun-if-changed={}", parserpath.to_str().unwrap()); ```
The only public function is [add_wasm_headers
]. See its documentation for some
more information.