blob: 52b21c66d27541af4dbb1aa11d697e1179d17240 [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
Jan Kundrátfe5a7922018-08-29 10:46:29 +020015 CMAKE_OPTIONS="${CMAKE_OPTIONS} -DUSE_SR_MEM_MGMT:BOOL=OFF"
Jan Kundrátd9d26a92018-02-22 12:49:21 +010016 # https://gitlab.kitware.com/cmake/cmake/issues/16609
17 CMAKE_OPTIONS="${CMAKE_OPTIONS} -DTHREADS_HAVE_PTHREAD_ARG:BOOL=ON"
18fi
19
20# force-enable tests for packages which use, eh, interesting setup
21# - libyang and libnetconf2 copmare CMAKE_BUILD_TYPE to lowercase "debug"...
22CMAKE_OPTIONS="${CMAKE_OPTIONS} -DENABLE_BUILD_TESTS=ON -DENABLE_VALGRIND_TESTS=OFF"
23
Jan Kundrátfe5a7922018-08-29 10:46:29 +020024# nuke python2 builds because we cannot write to the site_path
25CMAKE_OPTIONS="${CMAKE_OPTIONS} -DGEN_PYTHON_BINDINGS=OFF"
26
Jan Kundrátd47f6552018-03-02 13:40:11 +010027build_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átfe5a7922018-08-29 10:46:29 +020037build_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átd47f6552018-03-02 13:40:11 +010046do_test_dep_cmake() {
47 pushd ${TH_JOB_WORKING_DIR}/build-$1
48 shift
49 ${CTEST} --output-on-failure "$@"
50 popd
51}
52
53emerge_dep() {
54 if [[ -f ${TH_GIT_PATH}/submodules/$1/CMakeLists.txt ]]; then
55 build_dep_cmake $1
Jan Kundrátfe5a7922018-08-29 10:46:29 +020056 elif [[ -f ${TH_GIT_PATH}/submodules/$1/configure ]]; then
57 build_dep_autoconf "$@"
Jan Kundrátd47f6552018-03-02 13:40:11 +010058 else
59 echo "Unrecognized buildsystem for $1"
60 exit 1
61 fi
62}
63
64ARTIFACT=netconf-cli-$(git --git-dir ${TH_GIT_PATH}/.git rev-parse HEAD:submodules/).tar.xz
65
66scp th-ci-logs@ci-logs.gerrit.cesnet.cz:artifacts/${TH_JOB_NAME}/${ARTIFACT} . \
67 || true # ignore network errors
68
69if [[ -f ${TH_JOB_WORKING_DIR}/${ARTIFACT} ]]; then
70 tar -C ~/target -xvJf ${TH_JOB_WORKING_DIR}/${ARTIFACT}
71else
72 # rebuild everything from scratch
73
Jan Kundrát16a87942018-09-12 10:37:40 +020074 CMAKE_OPTIONS="${CMAKE_OPTIONS} -DGEN_LANGUAGE_BINDINGS=ON -DGEN_PYTHON_BINDINGS=OFF -DGEN_JAVA_BINDINGS=OFF" emerge_dep libyang
Jan Kundrátfe5a7922018-08-29 10:46:29 +020075 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átd47f6552018-03-02 13:40:11 +010085 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át03caee82018-03-08 14:16:56 +010098 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átd47f6552018-03-02 13:40:11 +0100104
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
110fi
111
Jan Kundrátd9d26a92018-02-22 12:49:21 +0100112mkdir -p ${ZUUL_PROJECT}/build
113cd ${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}
119ninja-build
120
121${CTEST} --output-on-failure