tree-sitter/script/generate-bindings
Max Brunsfeld 3fc459a84b Reorganize language bindings
* Move rust binding: lib/binding -> lib/binding_rust
* Move wasm bindinig: lib/web -> lib/binding_web
* Add wasm readme
2019-05-07 10:41:49 -07:00

24 lines
629 B
Bash
Executable file

#!/bin/bash
output_path=lib/binding_rust/bindings.rs
header_path='lib/include/tree_sitter/api.h'
bindgen \
--no-layout-tests \
--whitelist-type '^TS.*' \
--whitelist-function '^ts_.*' \
--opaque-type FILE \
--distrust-clang-mangling \
$header_path > $output_path
echo "" >> $output_path
defines=(
TREE_SITTER_LANGUAGE_VERSION
TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION
)
for define in ${defines[@]}; do
define_value=$(egrep "#define $define (.*)" $header_path | cut -d' ' -f3)
echo "pub const $define: usize = $define_value;" >> $output_path
done