Jan Kundrát | d9d26a9 | 2018-02-22 12:49:21 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -eux -o pipefail |
| 4 | shopt -s failglob |
| 5 | |
| 6 | # We're reusing our artifacts, so we absolutely need a stable destdir. |
| 7 | # Turbo-hipster takes care of cleaning up the mess betweeb builds. |
| 8 | PREFIX=~/target |
| 9 | mkdir ${PREFIX} |
| 10 | export PATH=${PREFIX}/bin:$PATH |
Jan Kundrát | 796c64c | 2018-05-26 18:49:11 +0200 | [diff] [blame] | 11 | export LD_LIBRARY_PATH=${PREFIX}/lib64:${PREFIX}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} |
| 12 | export PKG_CONFIG_PATH=${PREFIX}/lib64/pkgconfig:${PREFIX}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH} |
Jan Kundrát | d9d26a9 | 2018-02-22 12:49:21 +0100 | [diff] [blame] | 13 | |
| 14 | if [[ $TH_JOB_NAME =~ .*-sanitizers-.* ]]; then |
| 15 | # https://gitlab.kitware.com/cmake/cmake/issues/16609 |
| 16 | CMAKE_OPTIONS="${CMAKE_OPTIONS} -DTHREADS_HAVE_PTHREAD_ARG:BOOL=ON" |
| 17 | fi |
| 18 | |
| 19 | # force-enable tests for packages which use, eh, interesting setup |
| 20 | # - libyang and libnetconf2 copmare CMAKE_BUILD_TYPE to lowercase "debug"... |
| 21 | CMAKE_OPTIONS="${CMAKE_OPTIONS} -DENABLE_BUILD_TESTS=ON -DENABLE_VALGRIND_TESTS=OFF" |
| 22 | |
Jan Kundrát | d47f655 | 2018-03-02 13:40:11 +0100 | [diff] [blame] | 23 | build_dep_cmake() { |
| 24 | pushd ${TH_JOB_WORKING_DIR} |
| 25 | mkdir build-$1 |
| 26 | pushd build-$1 |
| 27 | ${CMAKE} -GNinja ${CMAKE_OPTIONS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} -DCMAKE_INSTALL_PREFIX=${PREFIX} ${TH_GIT_PATH}/submodules/$1 |
| 28 | ninja-build install |
| 29 | popd |
| 30 | popd |
| 31 | } |
| 32 | |
| 33 | do_test_dep_cmake() { |
| 34 | pushd ${TH_JOB_WORKING_DIR}/build-$1 |
| 35 | shift |
| 36 | ${CTEST} --output-on-failure "$@" |
| 37 | popd |
| 38 | } |
| 39 | |
| 40 | emerge_dep() { |
| 41 | if [[ -f ${TH_GIT_PATH}/submodules/$1/CMakeLists.txt ]]; then |
| 42 | build_dep_cmake $1 |
| 43 | else |
| 44 | echo "Unrecognized buildsystem for $1" |
| 45 | exit 1 |
| 46 | fi |
| 47 | } |
| 48 | |
| 49 | ARTIFACT=netconf-cli-$(git --git-dir ${TH_GIT_PATH}/.git rev-parse HEAD:submodules/).tar.xz |
| 50 | |
| 51 | scp th-ci-logs@ci-logs.gerrit.cesnet.cz:artifacts/${TH_JOB_NAME}/${ARTIFACT} . \ |
| 52 | || true # ignore network errors |
| 53 | |
| 54 | if [[ -f ${TH_JOB_WORKING_DIR}/${ARTIFACT} ]]; then |
| 55 | tar -C ~/target -xvJf ${TH_JOB_WORKING_DIR}/${ARTIFACT} |
| 56 | else |
| 57 | # rebuild everything from scratch |
| 58 | |
| 59 | emerge_dep Catch |
| 60 | do_test_dep_cmake Catch -j${CI_PARALLEL_JOBS} |
| 61 | |
| 62 | # Trompeloeil is a magic snowflake because it attempts to download and build Catch and kcov when building in a debug mode... |
| 63 | CMAKE_BUILD_TYPE=Release emerge_dep trompeloeil |
| 64 | |
| 65 | emerge_dep docopt.cpp |
| 66 | do_test_dep_cmake docopt.cpp -j${CI_PARALLEL_JOBS} |
| 67 | |
| 68 | emerge_dep spdlog |
| 69 | do_test_dep_cmake spdlog -j${CI_PARALLEL_JOBS} |
| 70 | |
| 71 | # boost-spirit doesn't require installation |
Jan Kundrát | 03caee8 | 2018-03-08 14:16:56 +0100 | [diff] [blame] | 72 | pushd ${TH_GIT_PATH}/submodules/boost |
| 73 | git submodule update --init |
| 74 | ./bootstrap.sh --prefix=${PREFIX} |
| 75 | ./b2 --ignore-site-config headers |
| 76 | cp -LR boost ${PREFIX}/include/ |
| 77 | popd |
Jan Kundrát | d47f655 | 2018-03-02 13:40:11 +0100 | [diff] [blame] | 78 | |
Jan Kundrát | e05448a | 2018-06-13 15:54:33 +0200 | [diff] [blame] | 79 | CMAKE_OPTIONS="${CMAKE_OPTIONS} -DGEN_LANGUAGE_BINDINGS=ON -DGEN_PYTHON_BINDINGS=OFF" emerge_dep libyang |
| 80 | do_test_dep_cmake libyang -j${CI_PARALLEL_JOBS} |
| 81 | |
Jan Kundrát | d47f655 | 2018-03-02 13:40:11 +0100 | [diff] [blame] | 82 | tar -C ~/target -cvJf ${TH_JOB_WORKING_DIR}/${ARTIFACT} . |
| 83 | ssh th-ci-logs@ci-logs.gerrit.cesnet.cz mkdir -p artifacts/${TH_JOB_NAME} \ |
| 84 | || true # ignore network errors |
| 85 | rsync ${TH_JOB_WORKING_DIR}/${ARTIFACT} th-ci-logs@ci-logs.gerrit.cesnet.cz:artifacts/${TH_JOB_NAME}/ \ |
| 86 | || true # ignore network errors |
| 87 | fi |
| 88 | |
Jan Kundrát | d9d26a9 | 2018-02-22 12:49:21 +0100 | [diff] [blame] | 89 | mkdir -p ${ZUUL_PROJECT}/build |
| 90 | cd ${ZUUL_PROJECT}/build |
| 91 | ${CMAKE} -GNinja \ |
| 92 | -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \ |
| 93 | -DCMAKE_INSTALL_PREFIX=${PREFIX} \ |
| 94 | ${CMAKE_OPTIONS} \ |
| 95 | ${TH_GIT_PATH} |
| 96 | ninja-build |
| 97 | |
| 98 | ${CTEST} --output-on-failure |