-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-bindings.sh
More file actions
executable file
·40 lines (34 loc) · 1.05 KB
/
update-bindings.sh
File metadata and controls
executable file
·40 lines (34 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
set -euo pipefail
# Regenerate src/bindings.rs from the librdb C headers.
# Requires: cargo install bindgen-cli
#
# Usage:
# cd librdb-sys
# ./update-bindings.sh
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
LIBRDB_ROOT="$SCRIPT_DIR/librdb"
WRAPPER_H="$SCRIPT_DIR/wrapper.h"
OUTPUT="$SCRIPT_DIR/src/bindings.rs"
if ! command -v bindgen &>/dev/null; then
echo "error: bindgen-cli not found. Install with: cargo install bindgen-cli" >&2
exit 1
fi
# Clang args (the -I include paths) must follow `--`; bindgen derives Debug by
# default, so only Default needs an explicit flag.
bindgen "$WRAPPER_H" \
--allowlist-function 'RDB_.*' \
--allowlist-function 'RDBX_.*' \
--allowlist-type 'Rdb.*' \
--allowlist-type 'Rdbx.*' \
--allowlist-var 'RDB_.*' \
--allowlist-var 'RDBX_.*' \
--blocklist-var 'RDB_ARRAY_INSERT_IDX_NONE' \
--with-derive-default \
-o "$OUTPUT" \
-- \
-I "$LIBRDB_ROOT/api" \
-I "$LIBRDB_ROOT/src" \
-I "$LIBRDB_ROOT/deps/redis"
rustfmt "$OUTPUT"
echo "Generated $OUTPUT"