From b6ab8435d792e35e56955b17fd53ae73185746ab Mon Sep 17 00:00:00 2001 From: yhirose Date: Wed, 12 Feb 2025 12:49:20 -0500 Subject: [PATCH] Improve ABI check tool on macOS --- test/check-abi-compatibility.sh | 16 ++++++++-------- test/make-shared-library.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 8 deletions(-) create mode 100755 test/make-shared-library.sh diff --git a/test/check-abi-compatibility.sh b/test/check-abi-compatibility.sh index a7d9f87..ec3b211 100755 --- a/test/check-abi-compatibility.sh +++ b/test/check-abi-compatibility.sh @@ -13,12 +13,12 @@ OLD_VARS=_old_vars.txt NEW_VARS=_new_vars.txt # Extract function symbols from the old and new libraries -nm -C --defined-only $OLD_LIB | c++filt | awk '$2 ~ /[TW]/ {print substr($0, index($0,$3))}' | sort > $OLD_FUNCS -nm -C --defined-only $NEW_LIB | c++filt | awk '$2 ~ /[TW]/ {print substr($0, index($0,$3))}' | sort > $NEW_FUNCS +nm -C --defined-only $OLD_LIB | c++filt | awk '$2 ~ /[TWt]/ {print substr($0, index($0,$3))}' | sort > $OLD_FUNCS +nm -C --defined-only $NEW_LIB | c++filt | awk '$2 ~ /[TWt]/ {print substr($0, index($0,$3))}' | sort > $NEW_FUNCS # Extract variable symbols from the old and new libraries -nm -C --defined-only $OLD_LIB | c++filt | awk '$2 ~ /[BDG]/ {print substr($0, index($0,$3))}' | sort > $OLD_VARS -nm -C --defined-only $NEW_LIB | c++filt | awk '$2 ~ /[BDG]/ {print substr($0, index($0,$3))}' | sort > $NEW_VARS +nm -C --defined-only $OLD_LIB | c++filt | awk '$2 ~ /[BDGVs]/ {print substr($0, index($0,$3))}' | sort > $OLD_VARS +nm -C --defined-only $NEW_LIB | c++filt | awk '$2 ~ /[BDGVs]/ {print substr($0, index($0,$3))}' | sort > $NEW_VARS # Initialize error flag and message error_flag=0 @@ -28,21 +28,21 @@ error_message="" removed_funcs=$(comm -23 $OLD_FUNCS $NEW_FUNCS) if [ -n "$removed_funcs" ]; then error_flag=1 - error_message+="[Removed Functions]\n$removed_funcs\n" + error_message+="[Removed Functions]\n$removed_funcs\n\n" fi # Check for removed variable symbols removed_vars=$(comm -23 $OLD_VARS $NEW_VARS) if [ -n "$removed_vars" ]; then error_flag=1 - error_message+="[Removed Variables]\n$removed_vars\n" + error_message+="[Removed Variables]\n$removed_vars\n\n" fi # Check for added variable symbols added_vars=$(comm -13 $OLD_VARS $NEW_VARS) if [ -n "$added_vars" ]; then error_flag=1 - error_message+="[Added Variables]\n$added_vars\n" + error_message+="[Added Variables]\n$added_vars\n\n" fi # Remove temporary files @@ -50,7 +50,7 @@ rm -f $NEW_FUNCS $OLD_FUNCS $OLD_VARS $NEW_VARS # Display error messages if any if [ "$error_flag" -eq 1 ]; then - echo -e "$error_message" + echo -en "$error_message" echo "ABI compatibility check failed." exit 1 fi diff --git a/test/make-shared-library.sh b/test/make-shared-library.sh new file mode 100755 index 0000000..04f2fc0 --- /dev/null +++ b/test/make-shared-library.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +if [ "$#" -ne 1 ]; then + echo "Usage: $0 build_dir" + exit 1 +fi + +BUILD_DIR=$1 + +# Make the build directory +rm -rf $BUILD_DIR +mkdir -p $BUILD_DIR/out + +cd $BUILD_DIR + +# Build the version +git checkout $BUILD_DIR -q + +cmake \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_CXX_FLAGS="-g -Og" \ + -DBUILD_SHARED_LIBS=ON \ + -DHTTPLIB_COMPILE=ON \ + -DCMAKE_INSTALL_PREFIX=./out \ + ../.. + +cmake --build . --target install +cmake --build . --target clean +