refactor(scripts): clean up bash scripts

This commit is contained in:
ObserverOfTime 2024-03-28 17:33:55 +02:00
parent 3950dddfde
commit f50123a3ec
18 changed files with 241 additions and 261 deletions

View file

@ -1,7 +1,7 @@
#!/bin/bash
output_path=lib/binding_rust/bindings.rs
header_path='lib/include/tree_sitter/api.h'
header_path=lib/include/tree_sitter/api.h
no_derive_copy=(
TSInput
TSLanguage
@ -19,13 +19,13 @@ no_copy=$(IFS='|'; echo "${no_derive_copy[*]}")
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)
higher_version=$(printf '%s\n' "$file_version" "$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
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
exit 1
fi
@ -33,11 +33,11 @@ bindgen \
--no-layout-tests \
--allowlist-type '^TS.*' \
--allowlist-function '^ts_.*' \
--allowlist-var "^TREE_SITTER.*" \
--allowlist-var '^TREE_SITTER.*' \
--blocklist-type '^__.*' \
--no-prepend-enum-name \
--no-copy "$no_copy" \
$header_path \
"$header_path" \
-- \
-D TREE_SITTER_FEATURE_WASM \
> $output_path
> "$output_path"