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 |
| 11 | export LD_LIBRARY_PATH=${PREFIX}/lib64:${PREFIX}/lib |
| 12 | export PKG_CONFIG_PATH=${PREFIX}/lib64/pkgconfig:${PREFIX}/lib/pkgconfig |
| 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 |
| 72 | |
| 73 | tar -C ~/target -cvJf ${TH_JOB_WORKING_DIR}/${ARTIFACT} . |
| 74 | ssh th-ci-logs@ci-logs.gerrit.cesnet.cz mkdir -p artifacts/${TH_JOB_NAME} \ |
| 75 | || true # ignore network errors |
| 76 | rsync ${TH_JOB_WORKING_DIR}/${ARTIFACT} th-ci-logs@ci-logs.gerrit.cesnet.cz:artifacts/${TH_JOB_NAME}/ \ |
| 77 | || true # ignore network errors |
| 78 | fi |
| 79 | |
Jan Kundrát | d9d26a9 | 2018-02-22 12:49:21 +0100 | [diff] [blame] | 80 | mkdir -p ${ZUUL_PROJECT}/build |
| 81 | cd ${ZUUL_PROJECT}/build |
| 82 | ${CMAKE} -GNinja \ |
| 83 | -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \ |
| 84 | -DCMAKE_INSTALL_PREFIX=${PREFIX} \ |
| 85 | ${CMAKE_OPTIONS} \ |
| 86 | ${TH_GIT_PATH} |
| 87 | ninja-build |
| 88 | |
| 89 | ${CTEST} --output-on-failure |