1#!/bin/bash 2 3# Script originally based on GTK+'s own abicheck.sh; it should be run anytime 4# there is a change in the stable branch of wxWidgets which could lead to an 5# ABI breakage and thus result in a binary-incompatible change (see tech docs). 6# 7 8 9expected_abi_file="expected_abi" 10actual_abi_file="actual_abi" 11 12if [[ "$1" == "--generate" ]]; then 13 14 # IMPORTANT: we need a shared build of wxWidgets to proceed 15 if [[ $(echo *.so) == "*.so" ]]; then 16 echo "No shared objects (*.so) were found... aborting" 17 exit 1 18 fi 19 20 # generated the "expected ABI" for later comparison 21 rm -f $expected_abi_file 22 for library in *.so; do 23 # NOTE: don't use -C option as otherwise cut won't work correctly 24 nm -D -g --defined-only $library | cut -d ' ' -f 3 | sort >>$expected_abi_file 25 done 26 27 echo "Expected wxWidgets ABI generated in \"$expected_abi_file\"..." 28 29elif [[ -z "$1" ]]; then 30 31 if [[ ! -f "$expected_abi_file" ]]; then 32 echo "The file containing the expected wxWidgets ABI '$expected_abi_file' does not exist!" 33 echo "Please generate it first using the '--generate' option" 34 exit 1 35 fi 36 37 echo "Comparing actual ABI with the expected ABI (loading it from \"$expected_abi_file\")..." 38 39 # IMPORTANT: we need a shared build of wxWidgets to do the check 40 if [[ $(echo *.so) == "*.so" ]]; then 41 echo "No shared objects (*.so) were found... aborting" 42 exit 1 43 fi 44 45 rm -f $actual_abi_file 46 for library in *.so; do 47 # NOTE: don't use -C option as otherwise cut won't work correctly 48 nm -D -g --defined-only $library | cut -d ' ' -f 3 | sort >>$actual_abi_file 49 done 50 51 result=`diff -u $expected_abi_file $actual_abi_file` 52 53 if [[ -z "$result" ]]; then 54 echo "No binary (in)compatible changes were found." 55 else 56 echo "=========================================================" 57 echo "WARNING: Possible binary-incompatible changes were found:" 58 echo "=========================================================" 59 echo 60 echo "$result" 61 62 # this doesn't necessarly indicate that binary compatibility was surely 63 # broken; e.g. adding non-virtual methods will generate a new line in the 64 # $actual_abi_file but that's a compatible change. 65 fi 66 67else 68 69 echo "Usage: $0 [--generate]" 70 echo "When running without options, compares the wxWidgets ABI saved in '$expected_abi_file'" 71 echo "with the current ABI of the .so files of the working directory." 72 echo "When --generate is given, saves in '$expected_abi_file' the ABI of the .so files" 73 echo "(for later comparisons)." 74 75fi 76 77