csecp256k1

Haskell FFI bindings to bitcoin-core/secp256k1 (docs.ppad.tech/csecp256k1).
git clone git://git.ppad.tech/csecp256k1.git
Log | Files | Refs | README | LICENSE

check-abi.sh (2265B)


      1 #!/bin/sh
      2 
      3 set -eu
      4 
      5 default_base_version="$(git describe --match "v*.*.*" --abbrev=0)"
      6 default_new_version="HEAD"
      7 
      8 display_help_and_exit() {
      9     echo "Usage: $0 [<base_ver> [<new_ver>]]"
     10     echo ""
     11     echo "Description: This script uses the ABI Compliance Checker tool to determine if the ABI"
     12     echo "             of a new version of libsecp256k1 has changed in a backward-incompatible way."
     13     echo ""
     14     echo "Options:"
     15     echo "  base_ver      Specify the base version as a git commit-ish"
     16     echo "                  (default: most recent reachable tag matching \"v.*.*\", currently \"$default_base_version\")"
     17     echo "  new_ver       Specify the new version as a git commit-ish"
     18     echo "                  (default: $default_new_version)"
     19     echo "  -h, --help    Display this help message"
     20     exit 0
     21 }
     22 
     23 if [ "$#" -eq 0 ]; then
     24     base_version="$default_base_version"
     25     new_version="$default_new_version"
     26 elif [ "$#" -eq 1 ] && { [ "$1" = "-h" ] || [ "$1" = "--help" ]; }; then
     27     display_help_and_exit
     28 elif [ "$#" -eq 1 ] || [ "$#" -eq 2 ]; then
     29     base_version="$1"
     30     if [ "$#" -eq 2 ]; then
     31         new_version="$2"
     32     fi
     33 else
     34     echo "Invalid usage. See help:"
     35     echo ""
     36     display_help_and_exit
     37 fi
     38 
     39 checkout_and_build() {
     40     _orig_dir="$(pwd)"
     41     git worktree add --detach "$1" "$2"
     42     cd "$1"
     43     mkdir build && cd build
     44     cmake -S .. --preset dev-mode \
     45         -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE=None -DCMAKE_C_FLAGS="-g -Og -gdwarf-4" \
     46         -DSECP256K1_BUILD_BENCHMARK=OFF \
     47         -DSECP256K1_BUILD_TESTS=OFF \
     48         -DSECP256K1_BUILD_EXHAUSTIVE_TESTS=OFF \
     49         -DSECP256K1_BUILD_CTIME_TESTS=OFF \
     50         -DSECP256K1_BUILD_EXAMPLES=OFF
     51     cmake --build . -j "$(nproc)"
     52     abi-dumper src/libsecp256k1.so -o ABI.dump -lver "$2"
     53     cd "$_orig_dir"
     54 }
     55 
     56 echo "Comparing $base_version (base version) to $new_version (new version)"
     57 echo
     58 
     59 base_source_dir="$(mktemp -d)"
     60 checkout_and_build "$base_source_dir" "$base_version"
     61 
     62 new_source_dir="$(mktemp -d)"
     63 checkout_and_build "$new_source_dir" "$new_version"
     64 
     65 abi-compliance-checker -lib libsecp256k1 -old "${base_source_dir}/build/ABI.dump" -new "${new_source_dir}/build/ABI.dump"
     66 git worktree remove "$base_source_dir"
     67 git worktree remove "$new_source_dir"