diff --git a/.github/depends/boost.sh b/.github/depends/boost.sh index 464c4382..6aba0d85 100755 --- a/.github/depends/boost.sh +++ b/.github/depends/boost.sh @@ -11,11 +11,9 @@ EOL build_boost() { - mkdir $3 || exit 1 ./b2 \ - -j4 \ --toolset=$1 \ - --prefix=$3 \ + --prefix=$3/$2 \ --with-test \ --with-headers \ --with-chrono \ @@ -50,6 +48,7 @@ while getopts "b:t:p:" c; do esac done +mkdir $prefix || exit 1 wget https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2 || exit 1 tar xf boost_1_76_0.tar.bz2 || exit 1 cd boost_1_76_0 diff --git a/.github/depends/zlib.sh b/.github/depends/zlib.sh index 5c1e1fe8..feaf807e 100755 --- a/.github/depends/zlib.sh +++ b/.github/depends/zlib.sh @@ -15,7 +15,7 @@ while getopts "b:t:p:" c; do case "$c" in b) bit="$OPTARG" - [ "$bit" != "32" ] && [ "$bit" != "64" ] && usage && exit 1 + [ "$bit" != "32" ] && [ "$bit" != "64" ] && [ "$bit" != "both" ] && usage && exit 1 ;; p) prefix="$OPTARG" @@ -26,15 +26,26 @@ while getopts "b:t:p:" c; do esac done +mkdir $prefix || exit 1 wget https://zlib.net/zlib-1.2.11.tar.gz || exit 1 tar -xf zlib-1.2.11.tar.gz || exit 1 cd zlib-1.2.11 -mkdir $prefix -cmake \ +build() +{ + cmake \ -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_INSTALL_PREFIX=$prefix \ - -D CMAKE_C_FLAGS="-m${bit}" \ - -D CMAKE_SHARED_LINKER_FLAGS="-m${bit}" \ + -D CMAKE_INSTALL_PREFIX=$2/$1 \ + -D CMAKE_C_FLAGS="-m$1" \ + -D CMAKE_SHARED_LINKER_FLAGS="-m$1" \ + -B build$1 \ -S . -cmake --build . --target install + cmake --build build$1 --target install +} + +if [ "$bit" = "both" ]; then + build 32 $prefix + build 64 $prefix +else + build $bit $prefix +fi diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f5483cbd..8c3bf1ed 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -16,10 +16,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: install depends + - name: Install build dependencies run: | sudo apt-get update - sudo apt-get install g++-10-multilib lcov -y + sudo apt-get install g++-10 cmake lcov -y ./ci/set_gcc_10.sh - name: Cache boost @@ -27,22 +27,22 @@ jobs: uses: actions/cache@v1 with: path: ~/boost-prefix/ - key: ${{ runner.os }}-boost-64-1-76-0-20210613 + key: ${{ runner.os }}-boost-64-1-76-0-2021-08-09 - name: Build boost if: steps.cache-boost.outputs.cache-hit != 'true' - run: ./.github/depends/boost.sh -b 64 -t gcc -p $HOME/boost-prefix/ + run: ./.github/depends/boost.sh -b 64 -t gcc -p $HOME/boost-prefix - name: Cache zlib id: cache-zlib uses: actions/cache@v1 with: path: ~/zlib-prefix/ - key: ${{ runner.os }}-zlib-64-1-2-11-20210613 + key: ${{ runner.os }}-zlib-64-1-2-11-2021-08-09 - name: Build zlib if: steps.cache-zlib.outputs.cache-hit != 'true' - run: ./.github/depends/zlib.sh -b 64 -p $HOME/zlib-prefix/ + run: ./.github/depends/zlib.sh -b 64 -p $HOME/zlib-prefix - name: Compile tests run: | @@ -56,7 +56,7 @@ jobs: -D MSGPACK_BUILD_TESTS=ON \ -D CMAKE_BUILD_TYPE=Debug \ -D MSGPACK_GEN_COVERAGE=ON \ - -D CMAKE_PREFIX_PATH="$HOME/zlib-prefix;$HOME/boost-prefix" \ + -D CMAKE_PREFIX_PATH="$HOME/zlib-prefix/64;$HOME/boost-prefix/64" \ -B build \ -S . || exit 1 cmake --build build --target all || exit 1 diff --git a/.github/workflows/gha.yml b/.github/workflows/gha.yml index 0d440224..85ce3ef6 100644 --- a/.github/workflows/gha.yml +++ b/.github/workflows/gha.yml @@ -11,83 +11,79 @@ on: jobs: macos: - name: ${{ format('macOS arch={0} cxx{1} san={2} api={3} char={4} x3={5}', matrix.arch, matrix.cxx, matrix.sanitize, matrix.api, matrix.char_sign, matrix.x3_parse) }} + name: ${{ format('macOS (pattern {0})', matrix.pattern) }} runs-on: macos-latest strategy: fail-fast: false matrix: - arch: [64] - cxx: [98, 11, 14, 17, 20] - sanitize: ["no", "undefined"] - api: [1, 2, 3] - char_sign: ["unsigned", "signed"] - x3_parse: ["OFF", "ON"] + pattern: [0, 1, 2, 3, 4] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Cache boost id: cache-boost - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ~/boost-prefix/ - key: ${{ runner.os }}-boost-1-76-0-20210612 + key: ${{ runner.os }}-boost-1-76-0-2021-08-09 - name: Build boost if: steps.cache-boost.outputs.cache-hit != 'true' - run: ./.github/depends/boost.sh -b ${{ matrix.arch }} -t clang -p $HOME/boost-prefix/ + run: ./.github/depends/boost.sh -b 64 -t clang -p $HOME/boost-prefix - name: Cache zlib id: cache-zlib - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ~/zlib-prefix/ - key: ${{ runner.os }}-zlib-${{ matrix.arch }}-1-2-11-20210623 + key: ${{ runner.os }}-zlib-1-2-11-2021-08-09 - name: Build zlib if: steps.cache-zlib.outputs.cache-hit != 'true' - run: ./.github/depends/zlib.sh -b ${{ matrix.arch }} -p $HOME/zlib-prefix/ + run: ./.github/depends/zlib.sh -b 64 -p $HOME/zlib-prefix - name: Build and test shell: bash run: | - if [[ (${{ matrix.cxx }} -eq 98 || ${{ matrix.cxx }} -lt 14) && "${{ matrix.x3_parse }}" == "ON" ]]; then - echo "X3 parse is only supported with C++14 or newer - skip this configuration" - exit 0 - fi + # default configuration - overwrite its params later depending on matrix.pattern + export MSGPACK_CXX_VERSION="MSGPACK_CXX20=ON" + export ARCH=64 + export API_VERSION=3 + export CHAR_SIGN="signed" + export X3_PARSE="OFF" + export SANITIZE="-fsanitize=undefined -fno-sanitize-recover=all" - export ARCH="${{ matrix.arch }}" - export API_VERSION="${{ matrix.api }}" - export CHAR_SIGN="${{ matrix.char_sign }}" - export X3_PARSE="${{ matrix.x3_parse }}" - - if [ "${{ matrix.cxx }}" == "98" ]; then - export MSGPACK_CXX_VERSION="MSGPACK_CXX11=OFF" - else - export MSGPACK_CXX_VERSION="MSGPACK_CXX${{ matrix.cxx }}=ON" - fi - - if [ "${{ matrix.sanitize }}" != "no" ]; then - export SANITIZE="-fsanitize=${{ matrix.sanitize }} -fno-sanitize-recover=all" - fi + case ${{ matrix.pattern }} in + 0) + export MSGPACK_CXX_VERSION="MSGPACK_CXX11=OFF" + ;; + 1) + export API_VERSION=1 + ;; + 2) + export API_VERSION=2 + ;; + 3) + export X3_PARSE="ON" + ;; + 4) + export CHAR_SIGN="unsigned" + ;; + esac # build and test export CXX="clang++" - CMAKE_CXX_COMPILER="$CXX" CXXFLAGS="-Werror -g ${SANITIZE}" ci/build_cmake.sh + CMAKE_CXX_COMPILER="$CXX" CXXFLAGS="-Werror -g ${SANITIZE}" ci/build_cmake.sh || exit 1 cat Files.cmake| grep ".*\.[h|hpp]" | perl -pe 's/ //g' | sort > tmp1 && find include -name "*.h" -o -name "*.hpp" | sort > tmp2 && diff tmp1 tmp2 linux: - name: ${{ format('Linux {0} arch={1} cxx{2} san={3} api={4} char={5} x3={6}', matrix.compiler, matrix.arch, matrix.cxx, matrix.sanitize, matrix.api, matrix.char_sign, matrix.x3_parse) }} + name: ${{ format('Linux (pattern {0})', matrix.pattern) }} runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: - arch: [32, 64] - cxx: [98, 11, 14, 17, 20] - sanitize: ["no", "undefined"] - api: [1, 2, 3] - char_sign: ["unsigned", "signed"] - x3_parse: ["OFF", "ON"] + pattern: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] steps: - uses: actions/checkout@v2 @@ -96,67 +92,95 @@ jobs: run: | sudo apt-get update sudo apt-get install g++-10 cmake valgrind -y - if [ ${{ matrix.arch }} == 32 ]; then - sudo apt-get install g++-10-multilib -y - fi + sudo apt-get install g++-10-multilib -y # for 32-bit compile ./ci/set_gcc_10.sh - name: Cache boost id: cache-boost - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ~/boost-prefix/ - key: ${{ runner.os }}-boost-${{ matrix.arch }}-1-76-0-20210613 + key: ${{ runner.os }}-boost-1-76-0-2021-08-09 - name: Build boost if: steps.cache-boost.outputs.cache-hit != 'true' - run: ./.github/depends/boost.sh -b ${{ matrix.arch }} -t gcc -p $HOME/boost-prefix/ + run: ./.github/depends/boost.sh -b both -t gcc -p $HOME/boost-prefix - name: Cache zlib id: cache-zlib - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ~/zlib-prefix/ - key: ${{ runner.os }}-zlib-${{ matrix.arch }}-1-2-11-20210613 + key: ${{ runner.os }}-zlib-1-2-11-2021-08-09 - name: Build zlib if: steps.cache-zlib.outputs.cache-hit != 'true' - run: ./.github/depends/zlib.sh -b ${{ matrix.arch }} -p $HOME/zlib-prefix/ + run: ./.github/depends/zlib.sh -b both -p $HOME/zlib-prefix - name: Build and test shell: bash run: | - if [[ (${{ matrix.cxx }} -eq 98 || ${{ matrix.cxx }} -lt 14) && "${{ matrix.x3_parse }}" == "ON" ]]; then - echo "X3 parse is only supported with C++14 or newer - skip this configuration" - exit 0 - fi + # default configuration - overwrite its params later depending on matrix.pattern + export MSGPACK_CXX_VERSION="MSGPACK_CXX20=ON" + export ARCH=64 + export API_VERSION=3 + export CHAR_SIGN="signed" + export X3_PARSE="OFF" + export SANITIZE="-fsanitize=undefined -fno-sanitize-recover=all" + export ACTION="ci/build_cmake.sh" - export ARCH="${{ matrix.arch }}" - export API_VERSION="${{ matrix.api }}" - export CHAR_SIGN="${{ matrix.char_sign }}" - export X3_PARSE="${{ matrix.x3_parse }}" - - if [ "${{ matrix.cxx }}" == "98" ]; then - export MSGPACK_CXX_VERSION="MSGPACK_CXX11=OFF" - else - export MSGPACK_CXX_VERSION="MSGPACK_CXX${{ matrix.cxx }}=ON" - fi - - if [ "${{ matrix.sanitize }}" != "no" ]; then - export SANITIZE="-fsanitize=${{ matrix.sanitize }} -fno-sanitize-recover=all" - fi + case ${{ matrix.pattern }} in + 0) + export MSGPACK_CXX_VERSION="MSGPACK_CXX11=OFF" + ;; + 1) + export MSGPACK_CXX_VERSION="MSGPACK_CXX11=ON" + ;; + 2) + export MSGPACK_CXX_VERSION="MSGPACK_CXX14=ON" + ;; + 3) + export MSGPACK_CXX_VERSION="MSGPACK_CXX17=ON" + ;; + 4) + export MSGPACK_CXX_VERSION="MSGPACK_CXX20=ON" + ;; + 5) + export ARCH=32 + ;; + 6) + export API_VERSION=2 + ;; + 7) + export API_VERSION=1 + ;; + 8) + export CHAR_SIGN="unsigned" + ;; + 9) + export X3_PARSE="ON" + ;; + 10) + export ACTION="ci/build_regression.sh" + ;; + 11) + export ARCH=32 + export CHAR_SIGN="unsigned" + export X3_PARSE="ON" + ;; + esac # build and test # g++ export CXX="g++-10" - CMAKE_CXX_COMPILER="$CXX" CXXFLAGS="-Werror -g ${SANITIZE}" ci/build_cmake.sh + CMAKE_CXX_COMPILER="$CXX" CXXFLAGS="-Werror -g ${SANITIZE}" ci/build_cmake.sh || exit 1 # clang++ # with ubsan clang inserts undefined reference to `__mulodi4' on 32-bit build - skip this configuration - if ! [[ "${{ matrix.sanitize }}" == "undefined" && $ARCH -eq 32 ]]; then + if ! [[ $SANITIZE != "" && $ARCH -eq 32 ]]; then export CXX="clang++-10" - CMAKE_CXX_COMPILER="$CXX" CXXFLAGS="-Werror -g ${SANITIZE}" ci/build_cmake.sh + CMAKE_CXX_COMPILER="$CXX" CXXFLAGS="-Werror -g ${SANITIZE}" ci/build_cmake.sh || exit 1 fi cat Files.cmake| grep ".*\.[h|hpp]" | perl -pe 's/ //g' | sort > tmp1 && find include -name "*.h" -o -name "*.hpp" | sort > tmp2 && diff tmp1 tmp2 @@ -169,16 +193,16 @@ jobs: # MSVC2019 only supports /std:c++14, /std:c++17 and /std:c++latest cxx: [14, 17, 20] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - - name: Cache vcpkg + - name: Cache vcpkg dependencies id: cache-vcpkg - uses: actions/cache@v1.0.3 + uses: actions/cache@v2 with: path: C:/vcpkg/installed/x64-windows - key: ${{ runner.os }}-vcpkg-01072021 + key: ${{ runner.os }}-vcpkg-2021-08-09 - - name: Build dependencies + - name: Install vcpkg dependencies if: steps.cache-vcpkg.outputs.cache-hit != 'true' shell: powershell run: | diff --git a/ci/build_cmake.sh b/ci/build_cmake.sh index 9b114d85..a89c4464 100755 --- a/ci/build_cmake.sh +++ b/ci/build_cmake.sh @@ -1,10 +1,11 @@ #!/bin/bash -mkdir $CXX-build || exit 1 -mkdir $CXX-prefix || exit 1 +build_dir="$CXX-build" +prefix_dir="`pwd`/$CXX-prefix" +mkdir $build_dir || exit 1 +mkdir $prefix_dir || exit 1 -if [ "${ARCH}" == "32" ] -then +if [ "${ARCH}" == "32" ]; then export BIT32="ON" export ARCH_FLAG="-m32" else @@ -13,7 +14,7 @@ else fi cmake \ - -D CMAKE_PREFIX_PATH="$HOME/boost-prefix;$HOME/zlib-prefix" \ + -D CMAKE_PREFIX_PATH="${HOME}/boost-prefix/${ARCH};${HOME}/zlib-prefix/${ARCH}" \ -D MSGPACK_BUILD_TESTS=ON \ -D ${MSGPACK_CXX_VERSION} \ -D MSGPACK_32BIT=${BIT32} \ @@ -21,17 +22,16 @@ cmake \ -D MSGPACK_DEFAULT_API_VERSION=${API_VERSION} \ -D MSGPACK_USE_X3_PARSE=${X3_PARSE} \ -D CMAKE_CXX_FLAGS="${CXXFLAGS} ${ARCH_FLAG}" \ - -D CMAKE_INSTALL_PREFIX=`pwd`/$CXX-prefix \ - -B $CXX-build \ + -D CMAKE_INSTALL_PREFIX=$prefix_dir \ + -B $build_dir \ -S . || exit 1 -cmake --build $CXX-build --target install || exit 1 +cmake --build $build_dir --target install || exit 1 -ctest -VV --test-dir $CXX-build || exit 1 +ctest -VV --test-dir $build_dir || exit 1 -if [ "${ARCH}" != "32" ] && [ `uname` = "Linux" ] -then - ctest -T memcheck --test-dir $CXX-build | tee memcheck.log +if [ "${ARCH}" != "32" ] && [ `uname` = "Linux" ]; then + ctest -T memcheck --test-dir $build_dir | tee memcheck.log ret=${PIPESTATUS[0]} if [ $ret -ne 0 ] @@ -46,16 +46,15 @@ then fi fi -if [ "${ARCH}" != "32" ] -then +if [ "${ARCH}" != "32" ]; then cd test-install || exit 1 - mkdir $CXX-build + mkdir $build_dir cmake \ - -D CMAKE_PREFIX_PATH="`pwd`/../$CXX-prefix;$HOME/boost-prefix" \ - -B $CXX-build \ + -D CMAKE_PREFIX_PATH="$prefix_dir;${HOME}/boost-prefix/${ARCH}" \ + -B $build_dir \ -S . || exit 1 - cmake --build $CXX-build --target all || exit 1 + cmake --build $build_dir --target all || exit 1 - $CXX-build/test-install || exit 1 + $build_dir/test-install || exit 1 fi diff --git a/ci/build_regression.sh b/ci/build_regression.sh index 4ce05c8f..0d4b94b3 100755 --- a/ci/build_regression.sh +++ b/ci/build_regression.sh @@ -1,6 +1,7 @@ #!/bin/bash -mkdir build || exit 1 +build_dir="$CXX-build" +mkdir $build_dir || exit 1 if [ "${ARCH}" == "32" ] then @@ -9,16 +10,16 @@ then fi cmake \ - -D CMAKE_PREFIX_PATH="$HOME/boost-prefix;$HOME/zlib-prefix" \ + -D CMAKE_PREFIX_PATH="${HOME}/boost-prefix/${ARCH};${HOME}/zlib-prefix/${ARCH}" \ -D MSGPACK_FUZZ_REGRESSION="ON" \ -D ${MSGPACK_CXX_VERSION} \ -D MSGPACK_CHAR_SIGN=${CHAR_SIGN} \ -D MSGPACK_DEFAULT_API_VERSION=${API_VERSION} \ -D MSGPACK_USE_X3_PARSE=${X3_PARSE} \ -D CMAKE_CXX_FLAGS="${CXXFLAGS}" \ - -B build \ + -B $build_dir \ -S . || exit 1 -cmake --build . --target all || exit 1 +cmake --build $build_dir --target all || exit 1 -ctest -VV --test-dir build || exit 1 +ctest -VV --test-dir $build_dir || exit 1