Add OS X support to abicheck.sh

Make abicheck.sh work with *.dylib files and the nm that comes with
Xcode.
This commit is contained in:
Dimitri Schoolwerth
2015-05-25 04:38:08 +04:00
parent fec5f36139
commit 94f8d80b6a

View File

@@ -9,19 +9,27 @@
expected_abi_file="expected_abi" expected_abi_file="expected_abi"
actual_abi_file="actual_abi" actual_abi_file="actual_abi"
if [[ "$(uname)" == "Darwin" ]]; then
file_mask=*.dylib
nm_options="-g -U"
else
file_mask=*.so
nm_options="-D -g --defined-only"
fi
if [[ "$1" == "--generate" ]]; then if [[ "$1" == "--generate" ]]; then
# IMPORTANT: we need a shared build of wxWidgets to proceed # IMPORTANT: we need a shared build of wxWidgets to proceed
if [[ $(echo *.so) == "*.so" ]]; then if [[ $(echo $file_mask) == "$file_mask" ]]; then
echo "No shared objects (*.so) were found... aborting" echo "No shared objects ($file_mask) were found... aborting"
exit 1 exit 1
fi fi
# generated the "expected ABI" for later comparison # generated the "expected ABI" for later comparison
rm -f $expected_abi_file rm -f $expected_abi_file
for library in *.so; do for library in $file_mask; do
# NOTE: don't use -C option as otherwise cut won't work correctly # NOTE: don't use -C option as otherwise cut won't work correctly
nm -D -g --defined-only $library | cut -d ' ' -f 3 | sort >>$expected_abi_file nm $nm_options $library | cut -d ' ' -f 3 | sort >>$expected_abi_file
done done
echo "Expected wxWidgets ABI generated in \"$expected_abi_file\"..." echo "Expected wxWidgets ABI generated in \"$expected_abi_file\"..."
@@ -37,15 +45,15 @@ elif [[ -z "$1" ]]; then
echo "Comparing actual ABI with the expected ABI (loading it from \"$expected_abi_file\")..." echo "Comparing actual ABI with the expected ABI (loading it from \"$expected_abi_file\")..."
# IMPORTANT: we need a shared build of wxWidgets to do the check # IMPORTANT: we need a shared build of wxWidgets to do the check
if [[ $(echo *.so) == "*.so" ]]; then if [[ $(echo $file_mask) == "*$file_mask" ]]; then
echo "No shared objects (*.so) were found... aborting" echo "No shared objects ($file_mask) were found... aborting"
exit 1 exit 1
fi fi
rm -f $actual_abi_file rm -f $actual_abi_file
for library in *.so; do for library in $file_mask; do
# NOTE: don't use -C option as otherwise cut won't work correctly # NOTE: don't use -C option as otherwise cut won't work correctly
nm -D -g --defined-only $library | cut -d ' ' -f 3 | sort >>$actual_abi_file nm $nm_options $library | cut -d ' ' -f 3 | sort >>$actual_abi_file
done done
result=`diff -u $expected_abi_file $actual_abi_file` result=`diff -u $expected_abi_file $actual_abi_file`