| 1 | #! /usr/bin/env bash |
| 2 | |
| 3 | # Test the `buildtime_bindgen` feature. |
| 4 | |
| 5 | set -eu |
| 6 | |
| 7 | # Build using bindgen. |
| 8 | cargo clean |
| 9 | cargo build --features buildtime_bindgen |
| 10 | |
| 11 | # Set $target to current OS name. |
| 12 | os="$(uname -s)" |
| 13 | case "$os" in |
| 14 | "Darwin") |
| 15 | target="macos" |
| 16 | ;; |
| 17 | "Linux") |
| 18 | target="linux" |
| 19 | ;; |
| 20 | "FreeBSD") |
| 21 | target="freebsd" |
| 22 | ;; |
| 23 | *) |
| 24 | echo "Unknown OS: $os" |
| 25 | exit 1 |
| 26 | ;; |
| 27 | esac |
| 28 | |
| 29 | # Test that generated bindings match the prebuilt version. |
| 30 | prebuilt_bindings="./bindgen/bindings_$target.rs" |
| 31 | bindings=$(find ./target/debug/build -name "bindings.rs") |
| 32 | |
| 33 | echo "Comparing $bindings and $prebuilt_bindings" |
| 34 | diff "$bindings" "$prebuilt_bindings" |
| 35 | |
| 36 | exit 0 |