-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync_header.sh
More file actions
executable file
·49 lines (43 loc) · 1.33 KB
/
sync_header.sh
File metadata and controls
executable file
·49 lines (43 loc) · 1.33 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
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
#
# sync_header.sh — refresh include/itb.h from the C binding's public
# header.
#
# The C++ binding's RAII wrappers in include/itb/*.hpp call the C
# binding's `itb_*` API exclusively; the public C header is consumed
# verbatim. To avoid maintenance drift between the two sibling bindings,
# include/itb.h is a derived COPY of bindings/c/include/itb.h with a
# header stamp identifying its provenance.
#
# Run this script after every libitb ABI change (or any edit to the C
# binding's public header). The CI gate `check_header.sh` fails when the
# two files have drifted.
#
# Usage:
# ./sync_header.sh
set -eu
set -o pipefail
cd "$(dirname "$0")"
SCRIPT_DIR="$(pwd)"
SOURCE="../c/include/itb.h"
TARGET="include/itb.h"
if [ ! -f "$SOURCE" ]; then
echo "sync_header.sh: source header missing at $SOURCE" >&2
exit 1
fi
STAMP="\
/* AUTO-DERIVED FROM bindings/c/include/itb.h — DO NOT EDIT.
*
* The C++ binding's RAII wrappers under include/itb/ consume the
* libitb C ABI through this header verbatim. To keep the two sibling
* bindings in lock-step, run bindings/cpp/sync_header.sh after every
* libitb ABI change; the CI gate bindings/cpp/check_header.sh fails on
* drift.
*/
"
mkdir -p include
{
printf '%s\n' "$STAMP"
cat "$SOURCE"
} > "$TARGET"
echo "sync_header.sh: ${TARGET} refreshed from ${SOURCE}"