5 info
() { echo -e "\033[33;1m$1\033[0m"; }
6 fatal
() { echo >&2 -e "\033[31;1m$1\033[0m"; exit 1; }
7 success
() { echo >&2 -e "\033[32;1m$1\033[0m"; }
13 "--optimization=3 -Db_lto=true"
14 "--optimization=3 -Db_lto=false"
58 COMPILER
="${COMPILER:?}"
59 COMPILER_VERSION
="${COMPILER_VERSION:?}"
60 RELEASE
="$(lsb_release -cs)"
62 bash
-c "echo 'deb-src http://archive.ubuntu.com/ubuntu/ $RELEASE main restricted universe multiverse' >>/etc/apt/sources.list"
64 # Note: As we use postfixed clang/gcc binaries, we need to override $AR
65 # as well, otherwise meson falls back to ar from binutils which
66 # doesn't work with LTO
67 if [[ "$COMPILER" == clang
]]; then
68 CC
="clang-$COMPILER_VERSION"
69 CXX
="clang++-$COMPILER_VERSION"
70 AR
="llvm-ar-$COMPILER_VERSION"
71 # Latest LLVM stack deb packages provided by https://apt.llvm.org/
72 # Following snippet was borrowed from https://apt.llvm.org/llvm.sh
73 wget
-O - https
://apt.llvm.org
/llvm-snapshot.gpg.key | apt-key add
-
74 add-apt-repository
-y "deb http://apt.llvm.org/$RELEASE/ llvm-toolchain-$RELEASE-$COMPILER_VERSION main"
75 PACKAGES
+=(clang-
$COMPILER_VERSION lldb-
$COMPILER_VERSION lld-
$COMPILER_VERSION clangd-
$COMPILER_VERSION)
76 elif [[ "$COMPILER" == gcc
]]; then
77 CC
="gcc-$COMPILER_VERSION"
78 CXX
="g++-$COMPILER_VERSION"
79 AR
="gcc-ar-$COMPILER_VERSION"
80 # Latest gcc stack deb packages provided by
81 # https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
82 sudo add-apt-repository
-y ppa
:ubuntu-toolchain-r
/test
83 PACKAGES
+=(gcc-
$COMPILER_VERSION)
85 fatal
"Unknown compiler: $COMPILER"
88 # PPA with some newer build dependencies (like zstd)
89 add-apt-repository
-y ppa
:upstream-systemd-ci
/systemd-ci
91 apt-get
-y build-dep systemd
92 apt-get
-y install "${PACKAGES[@]}"
93 # Install the latest meson and ninja form pip, since the distro versions don't
94 # support all the features we need (like --optimization=). Since the build-dep
95 # command above installs the distro versions, let's install the pip ones just
96 # locally and add the local bin directory to the $PATH.
97 pip3
install --user -U meson ninja
98 export PATH
="$HOME/.local/bin:$PATH"
102 for args
in "${ARGS[@]}"; do
105 info
"Checking build with $args"
106 if ! AR
="$AR" CC
="$CC" CXX
="$CXX" CFLAGS
="-Werror" CXXFLAGS
="-Werror" meson
-Dtests=unsafe
-Dslow-tests=true
--werror $args build
; then
107 fatal
"meson failed with $args"
111 if ! ninja
-C build
; then
112 fatal
"ninja failed with $args"
117 success
"Build with $args passed in $SECONDS seconds"