blob: a7177ac39a9059f86ba85db8ded4ae628d91103d [file] [log] [blame]
Jan Kundrátd9d26a92018-02-22 12:49:21 +01001#!/bin/bash
2
3set -eux -o pipefail
4shopt -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.
8PREFIX=~/target
9mkdir ${PREFIX}
10export PATH=${PREFIX}/bin:$PATH
Jan Kundrát796c64c2018-05-26 18:49:11 +020011export LD_LIBRARY_PATH=${PREFIX}/lib64:${PREFIX}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
12export PKG_CONFIG_PATH=${PREFIX}/lib64/pkgconfig:${PREFIX}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
Jan Kundrátd9d26a92018-02-22 12:49:21 +010013
14if [[ $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"
17fi
18
19# force-enable tests for packages which use, eh, interesting setup
20# - libyang and libnetconf2 copmare CMAKE_BUILD_TYPE to lowercase "debug"...
21CMAKE_OPTIONS="${CMAKE_OPTIONS} -DENABLE_BUILD_TESTS=ON -DENABLE_VALGRIND_TESTS=OFF"
22
Jan Kundrátd47f6552018-03-02 13:40:11 +010023build_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
33do_test_dep_cmake() {
34 pushd ${TH_JOB_WORKING_DIR}/build-$1
35 shift
36 ${CTEST} --output-on-failure "$@"
37 popd
38}
39
40emerge_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
49ARTIFACT=netconf-cli-$(git --git-dir ${TH_GIT_PATH}/.git rev-parse HEAD:submodules/).tar.xz
50
51scp th-ci-logs@ci-logs.gerrit.cesnet.cz:artifacts/${TH_JOB_NAME}/${ARTIFACT} . \
52 || true # ignore network errors
53
54if [[ -f ${TH_JOB_WORKING_DIR}/${ARTIFACT} ]]; then
55 tar -C ~/target -xvJf ${TH_JOB_WORKING_DIR}/${ARTIFACT}
56else
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át03caee82018-03-08 14:16:56 +010072 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átd47f6552018-03-02 13:40:11 +010078
79 tar -C ~/target -cvJf ${TH_JOB_WORKING_DIR}/${ARTIFACT} .
80 ssh th-ci-logs@ci-logs.gerrit.cesnet.cz mkdir -p artifacts/${TH_JOB_NAME} \
81 || true # ignore network errors
82 rsync ${TH_JOB_WORKING_DIR}/${ARTIFACT} th-ci-logs@ci-logs.gerrit.cesnet.cz:artifacts/${TH_JOB_NAME}/ \
83 || true # ignore network errors
84fi
85
Jan Kundrátd9d26a92018-02-22 12:49:21 +010086mkdir -p ${ZUUL_PROJECT}/build
87cd ${ZUUL_PROJECT}/build
88${CMAKE} -GNinja \
89 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \
90 -DCMAKE_INSTALL_PREFIX=${PREFIX} \
91 ${CMAKE_OPTIONS} \
92 ${TH_GIT_PATH}
93ninja-build
94
95${CTEST} --output-on-failure