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 |
Jan Kundrát | fe5a792 | 2018-08-29 10:46:29 +0200 | [diff] [blame] | 15 | CMAKE_OPTIONS="${CMAKE_OPTIONS} -DUSE_SR_MEM_MGMT:BOOL=OFF" |
Jan Kundrát | d9d26a9 | 2018-02-22 12:49:21 +0100 | [diff] [blame] | 16 | # https://gitlab.kitware.com/cmake/cmake/issues/16609 |
| 17 | CMAKE_OPTIONS="${CMAKE_OPTIONS} -DTHREADS_HAVE_PTHREAD_ARG:BOOL=ON" |
| 18 | fi |
| 19 | |
| 20 | # force-enable tests for packages which use, eh, interesting setup |
| 21 | # - libyang and libnetconf2 copmare CMAKE_BUILD_TYPE to lowercase "debug"... |
| 22 | CMAKE_OPTIONS="${CMAKE_OPTIONS} -DENABLE_BUILD_TESTS=ON -DENABLE_VALGRIND_TESTS=OFF" |
| 23 | |
Jan Kundrát | fe5a792 | 2018-08-29 10:46:29 +0200 | [diff] [blame] | 24 | # nuke python2 builds because we cannot write to the site_path |
| 25 | CMAKE_OPTIONS="${CMAKE_OPTIONS} -DGEN_PYTHON_BINDINGS=OFF" |
| 26 | |
Jan Kundrát | d47f655 | 2018-03-02 13:40:11 +0100 | [diff] [blame] | 27 | build_dep_cmake() { |
| 28 | pushd ${TH_JOB_WORKING_DIR} |
| 29 | mkdir build-$1 |
| 30 | pushd build-$1 |
| 31 | ${CMAKE} -GNinja ${CMAKE_OPTIONS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} -DCMAKE_INSTALL_PREFIX=${PREFIX} ${TH_GIT_PATH}/submodules/$1 |
| 32 | ninja-build install |
| 33 | popd |
| 34 | popd |
| 35 | } |
| 36 | |
Jan Kundrát | fe5a792 | 2018-08-29 10:46:29 +0200 | [diff] [blame] | 37 | build_dep_autoconf() { |
| 38 | pushd ${TH_GIT_PATH}/submodules/$1 |
| 39 | shift |
| 40 | ./configure --prefix=${PREFIX} "$@" |
| 41 | make -j4 |
| 42 | make install |
| 43 | popd |
| 44 | } |
| 45 | |
Jan Kundrát | d47f655 | 2018-03-02 13:40:11 +0100 | [diff] [blame] | 46 | do_test_dep_cmake() { |
| 47 | pushd ${TH_JOB_WORKING_DIR}/build-$1 |
| 48 | shift |
| 49 | ${CTEST} --output-on-failure "$@" |
| 50 | popd |
| 51 | } |
| 52 | |
| 53 | emerge_dep() { |
| 54 | if [[ -f ${TH_GIT_PATH}/submodules/$1/CMakeLists.txt ]]; then |
| 55 | build_dep_cmake $1 |
Jan Kundrát | fe5a792 | 2018-08-29 10:46:29 +0200 | [diff] [blame] | 56 | elif [[ -f ${TH_GIT_PATH}/submodules/$1/configure ]]; then |
| 57 | build_dep_autoconf "$@" |
Jan Kundrát | d47f655 | 2018-03-02 13:40:11 +0100 | [diff] [blame] | 58 | else |
| 59 | echo "Unrecognized buildsystem for $1" |
| 60 | exit 1 |
| 61 | fi |
| 62 | } |
| 63 | |
| 64 | ARTIFACT=netconf-cli-$(git --git-dir ${TH_GIT_PATH}/.git rev-parse HEAD:submodules/).tar.xz |
| 65 | |
| 66 | scp th-ci-logs@ci-logs.gerrit.cesnet.cz:artifacts/${TH_JOB_NAME}/${ARTIFACT} . \ |
| 67 | || true # ignore network errors |
| 68 | |
| 69 | if [[ -f ${TH_JOB_WORKING_DIR}/${ARTIFACT} ]]; then |
| 70 | tar -C ~/target -xvJf ${TH_JOB_WORKING_DIR}/${ARTIFACT} |
| 71 | else |
| 72 | # rebuild everything from scratch |
| 73 | |
Jan Kundrát | 16a8794 | 2018-09-12 10:37:40 +0200 | [diff] [blame^] | 74 | CMAKE_OPTIONS="${CMAKE_OPTIONS} -DGEN_LANGUAGE_BINDINGS=ON -DGEN_PYTHON_BINDINGS=OFF -DGEN_JAVA_BINDINGS=OFF" emerge_dep libyang |
Jan Kundrát | fe5a792 | 2018-08-29 10:46:29 +0200 | [diff] [blame] | 75 | do_test_dep_cmake libyang -j${CI_PARALLEL_JOBS} |
| 76 | |
| 77 | emerge_dep libredblack --with-pic |
| 78 | |
| 79 | # sysrepo needs to use a persistent repo location |
| 80 | CMAKE_OPTIONS="${CMAKE_OPTIONS} -DREPOSITORY_LOC=${PREFIX}/etc-sysrepo" emerge_dep sysrepo |
| 81 | # These tests are only those which can run on the global repo. |
| 82 | # They also happen to fail when run in parallel. That's expected, they manipulate a shared repository. |
| 83 | do_test_dep_cmake sysrepo |
| 84 | |
Jan Kundrát | d47f655 | 2018-03-02 13:40:11 +0100 | [diff] [blame] | 85 | emerge_dep Catch |
| 86 | do_test_dep_cmake Catch -j${CI_PARALLEL_JOBS} |
| 87 | |
| 88 | # Trompeloeil is a magic snowflake because it attempts to download and build Catch and kcov when building in a debug mode... |
| 89 | CMAKE_BUILD_TYPE=Release emerge_dep trompeloeil |
| 90 | |
| 91 | emerge_dep docopt.cpp |
| 92 | do_test_dep_cmake docopt.cpp -j${CI_PARALLEL_JOBS} |
| 93 | |
| 94 | emerge_dep spdlog |
| 95 | do_test_dep_cmake spdlog -j${CI_PARALLEL_JOBS} |
| 96 | |
| 97 | # boost-spirit doesn't require installation |
Jan Kundrát | 03caee8 | 2018-03-08 14:16:56 +0100 | [diff] [blame] | 98 | pushd ${TH_GIT_PATH}/submodules/boost |
| 99 | git submodule update --init |
| 100 | ./bootstrap.sh --prefix=${PREFIX} |
| 101 | ./b2 --ignore-site-config headers |
| 102 | cp -LR boost ${PREFIX}/include/ |
| 103 | popd |
Jan Kundrát | d47f655 | 2018-03-02 13:40:11 +0100 | [diff] [blame] | 104 | |
| 105 | tar -C ~/target -cvJf ${TH_JOB_WORKING_DIR}/${ARTIFACT} . |
| 106 | ssh th-ci-logs@ci-logs.gerrit.cesnet.cz mkdir -p artifacts/${TH_JOB_NAME} \ |
| 107 | || true # ignore network errors |
| 108 | rsync ${TH_JOB_WORKING_DIR}/${ARTIFACT} th-ci-logs@ci-logs.gerrit.cesnet.cz:artifacts/${TH_JOB_NAME}/ \ |
| 109 | || true # ignore network errors |
| 110 | fi |
| 111 | |
Jan Kundrát | d9d26a9 | 2018-02-22 12:49:21 +0100 | [diff] [blame] | 112 | mkdir -p ${ZUUL_PROJECT}/build |
| 113 | cd ${ZUUL_PROJECT}/build |
| 114 | ${CMAKE} -GNinja \ |
| 115 | -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \ |
| 116 | -DCMAKE_INSTALL_PREFIX=${PREFIX} \ |
| 117 | ${CMAKE_OPTIONS} \ |
| 118 | ${TH_GIT_PATH} |
| 119 | ninja-build |
| 120 | |
| 121 | ${CTEST} --output-on-failure |