1111set -e
1212
1313CAPI_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
14+ header_file=" $CAPI_DIR /include/hyper.h"
1415header_file_backup=" $CAPI_DIR /include/hyper.h.backup"
15-
16+ verify_flag= $1
1617function cleanup {
1718 rm -rf " $WORK_DIR " || true
18- rm " $header_file_backup " || true
19+ if [[ " --verify" == " $verify_flag " ]]; then
20+ rm " $header_file_backup " || true
21+ fi
1922}
2023
2124trap cleanup EXIT
@@ -28,7 +31,10 @@ if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
2831 exit 1
2932fi
3033
31- cp " $CAPI_DIR /include/hyper.h" " $header_file_backup "
34+ # backup hyper.h
35+ if [[ " --verify" == " $verify_flag " ]]; then
36+ cp " $header_file " " $header_file_backup "
37+ fi
3238
3339# Expand just the ffi module
3440if ! RUSTFLAGS=' --cfg hyper_unstable_ffi' cargo expand --features client,http1,http2,ffi ::ffi 2> $WORK_DIR /expand_stderr.err > $WORK_DIR /expanded.rs; then
3945if ! cbindgen \
4046 --config " $CAPI_DIR /cbindgen.toml" \
4147 --lockfile " $CAPI_DIR /../Cargo.lock" \
42- --output " $CAPI_DIR /include/hyper.h " \
48+ --output " $header_file " \
4349 " ${@ } " \
4450 $WORK_DIR /expanded.rs 2> $WORK_DIR /cbindgen_stderr.err; then
4551 bindgen_exit_code=$?
46- if [[ " --verify" == " $1 " ]]; then
52+ if [[ " --verify" == " $verify_flag " ]]; then
4753 echo " Changes from previous header (old < > new)"
48- diff -u " $header_file_backup " " $CAPI_DIR /include/hyper.h "
54+ diff -u " $header_file_backup " " $header_file "
4955 else
5056 echo " cbindgen failed:"
5157 cat $WORK_DIR /cbindgen_stderr.err
0 commit comments