11
11
set -e
12
12
13
13
CAPI_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
14
+ header_file=" $CAPI_DIR /include/hyper.h"
14
15
header_file_backup=" $CAPI_DIR /include/hyper.h.backup"
15
-
16
+ verify_flag= $1
16
17
function cleanup {
17
18
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
19
22
}
20
23
21
24
trap cleanup EXIT
@@ -28,7 +31,10 @@ if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
28
31
exit 1
29
32
fi
30
33
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
32
38
33
39
# Expand just the ffi module
34
40
if ! RUSTFLAGS=' --cfg hyper_unstable_ffi' cargo expand --features client,http1,http2,ffi ::ffi 2> $WORK_DIR /expand_stderr.err > $WORK_DIR /expanded.rs; then
39
45
if ! cbindgen \
40
46
--config " $CAPI_DIR /cbindgen.toml" \
41
47
--lockfile " $CAPI_DIR /../Cargo.lock" \
42
- --output " $CAPI_DIR /include/hyper.h " \
48
+ --output " $header_file " \
43
49
" ${@ } " \
44
50
$WORK_DIR /expanded.rs 2> $WORK_DIR /cbindgen_stderr.err; then
45
51
bindgen_exit_code=$?
46
- if [[ " --verify" == " $1 " ]]; then
52
+ if [[ " --verify" == " $verify_flag " ]]; then
47
53
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 "
49
55
else
50
56
echo " cbindgen failed:"
51
57
cat $WORK_DIR /cbindgen_stderr.err
0 commit comments