abi-check.sh 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #!/bin/bash
  2. # This script executes the abi-check step when running under travis-ci (in run step)
  3. # Set-up some bash options
  4. set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
  5. set -o errexit ## set -e : exit the script if any statement returns a non-true return value
  6. set -o pipefail ## Fail on error in pipe
  7. set -o xtrace ## set -x : Print a trace of simple commands and their arguments after they are expanded and before they are executed.
  8. # Exit if not ABI check
  9. if [ "${OPJ_CI_ABI_CHECK:-}" != "1" ]; then
  10. exit 0
  11. fi
  12. if [ "${OPJ_CI_CC:-}" != "" ]; then
  13. export CC=${OPJ_CI_CC}
  14. echo "Using ${CC}"
  15. fi
  16. if [ "${OPJ_CI_CXX:-}" != "" ]; then
  17. export CXX=${OPJ_CI_CXX}
  18. echo "Using ${CXX}"
  19. fi
  20. OPJ_UPLOAD_ABI_REPORT=0
  21. #OPJ_PREVIOUS_VERSION="2.3.0"
  22. OPJ_LATEST_VERSION="2.3.1"
  23. if [ "${OPJ_PREVIOUS_VERSION:-}" != "" ]; then
  24. OPJ_LIMIT_ABI_BUILDS="-limit 3"
  25. else
  26. OPJ_LIMIT_ABI_BUILDS="-limit 2"
  27. fi
  28. OPJ_REPO="https://github.com/uclouvain/openjpeg.git"
  29. OPJ_SSH_REPO=${OPJ_REPO/https:\/\/github.com\//git@github.com:}
  30. OPJ_UPLOAD_BRANCH="gh-pages"
  31. OPJ_UPLOAD_DIR="abi-check"
  32. if [ "${TRAVIS_REPO_SLUG:-}" != "" ]; then
  33. if [ "$(echo "${TRAVIS_REPO_SLUG}" | sed 's/\(^.*\)\/.*/\1/')" == "uclouvain" ] && [ "${TRAVIS_PULL_REQUEST:-}" == "false" ] && [ "${TRAVIS_BRANCH:-}" == "master" ]; then
  34. # Upload updated report to gh-pages
  35. OPJ_UPLOAD_ABI_REPORT=1
  36. # Build full report
  37. #OPJ_LIMIT_ABI_BUILDS=
  38. fi
  39. fi
  40. OPJ_SOURCE_DIR=$(cd $(dirname $0)/../.. && pwd)
  41. # INSTALL REQUIRED PACKAGES
  42. mkdir ${HOME}/abi-check
  43. cd ${HOME}/abi-check
  44. # Let's get tools not available with apt
  45. mkdir tools
  46. # Travis doesn't allow package wdiff...
  47. wget -qO - http://mirrors.kernel.org/gnu/wdiff/wdiff-latest.tar.gz | tar -xz
  48. cd wdiff-*
  49. ./configure --prefix=${HOME}/abi-check/tools/wdiff &> /dev/null
  50. make &> /dev/null
  51. make check &> /dev/null
  52. make install &> /dev/null
  53. cd ..
  54. export PATH=${PWD}/tools/wdiff/bin:$PATH
  55. wget https://tools.ietf.org/tools/rfcdiff/rfcdiff
  56. chmod +x rfcdiff
  57. mv rfcdiff ${PWD}/tools
  58. export PATH=${PWD}/tools:$PATH
  59. wget -qO - https://github.com/lvc/installer/archive/0.10.tar.gz | tar -xz
  60. mkdir ${PWD}/tools/abi-tracker
  61. make -C installer-0.10 install prefix=${PWD}/tools/abi-tracker target=abi-tracker
  62. export PATH=${PWD}/tools/abi-tracker/bin:$PATH
  63. # This will print configuration
  64. # travis-ci doesn't dump cmake version in system info, let's print it
  65. cmake --version
  66. # RUN THE ABI-CHECK SCRIPTS
  67. mkdir work
  68. cd work
  69. # Clone the gh-pages branch and work from there
  70. git clone -b $OPJ_UPLOAD_BRANCH --single-branch $OPJ_REPO .
  71. cd $OPJ_UPLOAD_DIR
  72. rm -rf installed/openjpeg/current/*
  73. # Let's create all we need
  74. grep -v Git ${OPJ_SOURCE_DIR}/tools/abi-tracker/openjpeg.json > ./openjpeg.json
  75. abi-monitor ${OPJ_LIMIT_ABI_BUILDS} -get openjpeg.json
  76. if [ "${OPJ_LIMIT_ABI_BUILDS}" != "" ]; then
  77. cp -f ${OPJ_SOURCE_DIR}/tools/abi-tracker/openjpeg.json ./openjpeg.json
  78. else
  79. # Old versions of openjpeg don't like -fvisibility=hidden...
  80. grep -v Configure ${OPJ_SOURCE_DIR}/tools/abi-tracker/openjpeg.json > ./openjpeg.json
  81. fi
  82. cp -rf ${OPJ_SOURCE_DIR} src/openjpeg/current
  83. abi-monitor -v current -build openjpeg.json
  84. rm -rf ./installed/openjpeg/${OPJ_LATEST_VERSION}
  85. rm -rf ./compat_report/openjpeg/${OPJ_LATEST_VERSION}
  86. rm -rf ./abi_dump/openjpeg/${OPJ_LATEST_VERSION}
  87. rm -rf ./headers_diff/openjpeg/${OPJ_LATEST_VERSION}
  88. rm -rf ./objects_report/openjpeg/${OPJ_LATEST_VERSION}
  89. abi-monitor -v ${OPJ_LATEST_VERSION} -build openjpeg.json
  90. if [ "${OPJ_PREVIOUS_VERSION:-}" != "" ]; then
  91. abi-monitor -v ${OPJ_PREVIOUS_VERSION} -build openjpeg.json
  92. fi
  93. abi-tracker -build openjpeg.json
  94. EXIT_CODE=0
  95. # Check API
  96. abi-compliance-checker -l openjpeg -old $(find ./abi_dump/openjpeg/$OPJ_LATEST_VERSION -name '*.dump') -new $(find ./abi_dump/openjpeg/current -name '*.dump') -header openjpeg.h -api -s || EXIT_CODE=1
  97. if [ "${OPJ_PREVIOUS_VERSION:-}" != "" ]; then
  98. abi-compliance-checker -l openjpeg -old $(find ./abi_dump/openjpeg/$OPJ_PREVIOUS_VERSION -name '*.dump') -new $(find ./abi_dump/openjpeg/$OPJ_LATEST_VERSION -name '*.dump') -header openjpeg.h -api -s || EXIT_CODE=1
  99. fi
  100. # Check ABI
  101. if [ "${OPJ_LIMIT_ABI_BUILDS}" != "" ]; then
  102. abi-compliance-checker -l openjpeg -old $(find ./abi_dump/openjpeg/$OPJ_LATEST_VERSION -name '*.dump') -new $(find ./abi_dump/openjpeg/current -name '*.dump') -header openjpeg.h -abi -s || EXIT_CODE=1
  103. if [ ${EXIT_CODE} -eq 1 ]; then
  104. cat "compat_reports/openjpeg/${OPJ_LATEST_VERSION}_to_current/abi_compat_report.html"
  105. fi
  106. if [ "${OPJ_PREVIOUS_VERSION:-}" != "" ]; then
  107. abi-compliance-checker -l openjpeg -old $(find ./abi_dump/openjpeg/$OPJ_PREVIOUS_VERSION -name '*.dump') -new $(find ./abi_dump/openjpeg/$OPJ_LATEST_VERSION -name '*.dump') -header openjpeg.h -abi -s || EXIT_CODE=1
  108. fi
  109. else
  110. echo "Disable ABI check for now, problems with symbol visibility..."
  111. fi
  112. rm -rf src/openjpeg/current
  113. rm -rf build_logs
  114. if [ ${OPJ_UPLOAD_ABI_REPORT} -eq 1 ]; then
  115. git config user.name "OpenJPEG Travis CI"
  116. git config user.email "info@openjpeg.org"
  117. git add --all .
  118. git commit -m "Update ABI/API compatibility reports after commit ${TRAVIS_COMMIT:-}"
  119. # Get the deploy key by using Travis's stored variables to decrypt travis_rsa.enc
  120. openssl aes-256-cbc -K $encrypted_99d63218f67a_key -iv $encrypted_99d63218f67a_iv -in ${OPJ_SOURCE_DIR}/tools/travis-ci/travis_rsa.enc -out travis_rsa -d
  121. chmod 600 travis_rsa
  122. eval `ssh-agent -s`
  123. ssh-add travis_rsa
  124. # Now that we're all set up, we can push.
  125. git push $OPJ_SSH_REPO $OPJ_UPLOAD_BRANCH
  126. fi
  127. rm -rf src installed
  128. exit $EXIT_CODE