2016-07-10 14:03:00 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2019-05-07 10:27:45 -07:00
|
|
|
output_path=lib/binding_rust/bindings.rs
|
2019-01-10 15:22:39 -08:00
|
|
|
header_path='lib/include/tree_sitter/api.h'
|
2023-07-11 22:15:28 +03:00
|
|
|
no_derive_copy=(
|
|
|
|
|
TSInput
|
|
|
|
|
TSLanguage
|
|
|
|
|
TSLogger
|
2023-07-17 10:52:33 +03:00
|
|
|
TSLookaheadIterator
|
2023-07-11 22:15:28 +03:00
|
|
|
TSParser
|
|
|
|
|
TSTree
|
|
|
|
|
TSQuery
|
|
|
|
|
TSQueryCursor
|
|
|
|
|
TSQueryCapture
|
|
|
|
|
TSQueryMatch
|
|
|
|
|
TSQueryPredicateStep
|
|
|
|
|
)
|
|
|
|
|
no_copy=$(IFS='|'; echo "${no_derive_copy[*]}")
|
2016-07-10 14:03:00 -07:00
|
|
|
|
2023-07-13 00:36:16 +03:00
|
|
|
file_version=$(head -n1 "$output_path" | cut -d' ' -f6)
|
|
|
|
|
tool_version=$(bindgen --version | cut -d' ' -f2)
|
|
|
|
|
higher_version=$(echo -e "${file_version}\n${tool_version}" | sort -V | tail -n1)
|
|
|
|
|
|
|
|
|
|
if [ "$higher_version" != "$tool_version" ]; then
|
|
|
|
|
echo "Latest used bindgen version was $file_version" >&2
|
|
|
|
|
echo "Currently installed bindgen CLI version is $tool_version" >&2
|
|
|
|
|
echo >&2
|
|
|
|
|
echo "It's needed to upgrade bindgen CLI first with \`cargo install bindgen-cli\`" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2016-07-10 14:03:00 -07:00
|
|
|
|
2021-12-09 21:02:15 -08:00
|
|
|
bindgen \
|
|
|
|
|
--no-layout-tests \
|
2023-04-04 22:16:27 +03:00
|
|
|
--allowlist-type '^TS.*' \
|
|
|
|
|
--allowlist-function '^ts_.*' \
|
2023-08-20 16:10:13 +03:00
|
|
|
--allowlist-var "^TREE_SITTER.*" \
|
2021-12-09 21:02:15 -08:00
|
|
|
--blocklist-type '^__.*' \
|
2023-09-03 06:47:27 +03:00
|
|
|
--no-prepend-enum-name \
|
2023-07-11 22:15:28 +03:00
|
|
|
--no-copy "$no_copy" \
|
2022-01-03 10:57:01 -08:00
|
|
|
$header_path \
|
|
|
|
|
-- \
|
|
|
|
|
-D TREE_SITTER_FEATURE_WASM \
|
|
|
|
|
> $output_path
|