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
|
2024-03-28 17:33:55 +02: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)
|
2024-03-28 17:33:55 +02:00
|
|
|
higher_version=$(printf '%s\n' "$file_version" "$tool_version" | sort -V | tail -n1)
|
2023-07-13 00:36:16 +03:00
|
|
|
|
2024-03-28 17:33:55 +02:00
|
|
|
if [[ "$higher_version" != "$tool_version" ]]; then
|
|
|
|
|
printf 'Latest used bindgen version was %s\n' "$file_version" >&2
|
|
|
|
|
printf 'Currently installed bindgen CLI version is %s\n\n' "$tool_version" >&2
|
|
|
|
|
# shellcheck disable=SC2016
|
|
|
|
|
printf 'You must upgrade bindgen CLI first with `cargo install bindgen-cli`\n' >&2
|
2023-07-13 00:36:16 +03:00
|
|
|
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_.*' \
|
2024-03-28 17:33:55 +02: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" \
|
2024-08-29 17:21:52 -04:00
|
|
|
--use-core \
|
2024-03-28 17:33:55 +02:00
|
|
|
"$header_path" \
|
2022-01-03 10:57:01 -08:00
|
|
|
-- \
|
|
|
|
|
-D TREE_SITTER_FEATURE_WASM \
|
2024-03-28 17:33:55 +02:00
|
|
|
> "$output_path"
|