check-shared-library-abi-compatibility.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env bash
  2. PREVIOUS_VERSION=$(git describe --tags --abbrev=0 master)
  3. BUILD_DIR=_build_for_abi_compatibility_check
  4. # Make the build directory
  5. rm -rf $BUILD_DIR
  6. mkdir -p $BUILD_DIR/new
  7. mkdir -p $BUILD_DIR/old
  8. cd $BUILD_DIR
  9. # Build the current commit
  10. cd new
  11. cmake \
  12. -DCMAKE_BUILD_TYPE=Debug \
  13. -DCMAKE_CXX_FLAGS="-g -Og" \
  14. -DBUILD_SHARED_LIBS=ON \
  15. -DHTTPLIB_COMPILE=ON \
  16. -DCMAKE_INSTALL_PREFIX=./out \
  17. ../../.. > /dev/null
  18. cmake --build . --target install > /dev/null
  19. cmake --build . --target clean > /dev/null
  20. cd ..
  21. # Build the nearest vesion
  22. cd old
  23. cmake \
  24. -DCMAKE_BUILD_TYPE=Debug \
  25. -DCMAKE_CXX_FLAGS="-g -Og" \
  26. -DBUILD_SHARED_LIBS=ON \
  27. -DHTTPLIB_COMPILE=ON \
  28. -DCMAKE_INSTALL_PREFIX=./out \
  29. ../../.. > /dev/null
  30. git checkout -q "${PREVIOUS_VERSION}"
  31. cmake --build . --target install > /dev/null
  32. cmake --build . --target clean > /dev/null
  33. cd ..
  34. # Checkout the original commit
  35. git checkout -q master
  36. # ABI compatibility check
  37. if [[ "$OSTYPE" == "linux-gnu"* ]]; then
  38. ../check-abi-compatibility.sh ./old/out/lib/libcpp-httplib.so ./new/out/lib/libcpp-httplib.so
  39. exit $?
  40. elif [[ "$OSTYPE" == "darwin"* ]]; then
  41. ../check-abi-compatibility.sh ./old/out/lib/libcpp-httplib.dylib ./new/out/lib/libcpp-httplib.dylib
  42. exit $?
  43. else
  44. echo "Unknown OS..."
  45. exit 1
  46. fi