#tree-sitter #wasm-build #build #wasm #build-script

build tree-sitter-wasm-build-tool

A crate to easily allow tree-sitter parsers to compile to Rust’s wasm32-unknown-unknown target

4 releases

0.2.2 Sep 20, 2023
0.2.1 Sep 20, 2023
0.2.0 Aug 1, 2023
0.1.0 Mar 28, 2023

#361 in Build Utils

Download history 28/week @ 2024-04-02 10/week @ 2024-04-09 7/week @ 2024-04-16 9/week @ 2024-04-23 1/week @ 2024-05-07 3/week @ 2024-05-14 3/week @ 2024-05-21 21/week @ 2024-05-28 9/week @ 2024-06-04

72 downloads per month
Used in 4 crates (3 directly)

GPL-3.0-only

16KB

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:

let src_dir = std::path::Path::new("src");
let mut c_config = cc::Build::new();
c_config.include(src_dir);
c_config
    .flag("-Wno-unused-parameter")
    .flag("-Wno-unused-but-set-variable")
    .flag("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
c_config.file(&parser_path);

#[cfg(feature = "c2rust")]
tree_sitter_wasm_build_tool::add_wasm_headers(&mut c_config).unwrap();

c_config.compile("parser");
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());

The only public function is add_wasm_headers. See its documentation for some more information.

Dependencies

~185KB