2020-06-10 14:41:28 +03:00
#!/bin/bash
2020-06-11 14:18:07 +03:00
set -ex
2020-06-10 14:41:28 +03:00
info( ) { echo -e " \033[33;1m $1 \033[0m " ; }
2020-06-11 14:18:07 +03:00
fatal( ) { echo >& 2 -e " \033[31;1m $1 \033[0m " ; exit 1; }
2020-06-10 14:41:28 +03:00
success( ) { echo >& 2 -e " \033[32;1m $1 \033[0m " ; }
ARGS = (
"--optimization=0"
"--optimization=2"
"--optimization=s"
2020-06-11 15:21:02 +03:00
"--optimization=3 -Db_lto=true"
"--optimization=3 -Db_lto=false"
2020-06-10 14:41:28 +03:00
"-Db_ndebug=true"
)
PACKAGES = (
cryptsetup-bin
2020-06-10 21:51:15 +03:00
expect
fdisk
2020-06-10 14:41:28 +03:00
gettext
iputils-ping
isc-dhcp-client
itstool
kbd
libblkid-dev
libcap-dev
libcurl4-gnutls-dev
2020-06-10 21:51:15 +03:00
libfdisk-dev
2020-10-21 17:28:22 +03:00
libfido2-dev
2020-06-10 14:41:28 +03:00
libgpg-error-dev
liblz4-dev
liblzma-dev
libmicrohttpd-dev
libmount-dev
2020-06-10 21:51:15 +03:00
libp11-kit-dev
libpwquality-dev
2020-06-10 14:41:28 +03:00
libqrencode-dev
2020-06-10 21:51:15 +03:00
libssl-dev
2020-06-10 14:41:28 +03:00
libxkbcommon-dev
2020-10-21 17:17:29 +03:00
libxtables-dev
2020-10-21 17:28:22 +03:00
libzstd-dev
2020-06-10 14:41:28 +03:00
mount
net-tools
perl
python-lxml
python3-evdev
python3-lxml
python3-pip
python3-pyparsing
python3-setuptools
quota
strace
unifont
util-linux
2020-06-10 21:51:15 +03:00
zstd
2020-06-10 14:41:28 +03:00
)
2020-06-11 14:18:07 +03:00
COMPILER = " ${ COMPILER : ? } "
COMPILER_VERSION = " ${ COMPILER_VERSION : ? } "
2020-06-10 14:41:28 +03:00
RELEASE = " $( lsb_release -cs) "
bash -c " echo 'deb-src http://archive.ubuntu.com/ubuntu/ $RELEASE main restricted universe multiverse' >>/etc/apt/sources.list "
2020-06-11 14:18:07 +03:00
# Note: As we use postfixed clang/gcc binaries, we need to override $AR
# as well, otherwise meson falls back to ar from binutils which
# doesn't work with LTO
if [ [ " $COMPILER " = = clang ] ] ; then
CC = " clang- $COMPILER_VERSION "
CXX = " clang++- $COMPILER_VERSION "
AR = " llvm-ar- $COMPILER_VERSION "
# Latest LLVM stack deb packages provided by https://apt.llvm.org/
# Following snippet was borrowed from https://apt.llvm.org/llvm.sh
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
add-apt-repository -y " deb http://apt.llvm.org/ $RELEASE / llvm-toolchain- $RELEASE - $COMPILER_VERSION main "
2020-06-11 16:00:15 +03:00
PACKAGES += ( clang-$COMPILER_VERSION lldb-$COMPILER_VERSION lld-$COMPILER_VERSION clangd-$COMPILER_VERSION )
2020-06-11 14:18:07 +03:00
elif [ [ " $COMPILER " = = gcc ] ] ; then
CC = " gcc- $COMPILER_VERSION "
CXX = " g++- $COMPILER_VERSION "
AR = " gcc-ar- $COMPILER_VERSION "
# Latest gcc stack deb packages provided by
# https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
2020-06-11 16:00:15 +03:00
PACKAGES += ( gcc-$COMPILER_VERSION )
2020-06-11 14:18:07 +03:00
else
fatal " Unknown compiler: $COMPILER "
fi
2020-06-10 21:51:15 +03:00
# PPA with some newer build dependencies (like zstd)
2020-07-15 00:47:43 +03:00
add-apt-repository -y ppa:upstream-systemd-ci/systemd-ci
2020-06-11 16:00:15 +03:00
apt-get -y update
2020-06-11 14:18:07 +03:00
apt-get -y build-dep systemd
apt-get -y install " ${ PACKAGES [@] } "
2020-06-11 16:00:15 +03:00
# Install the latest meson and ninja form pip, since the distro versions don't
# support all the features we need (like --optimization=). Since the build-dep
# command above installs the distro versions, let's install the pip ones just
# locally and add the local bin directory to the $PATH.
pip3 install --user -U meson ninja
export PATH = " $HOME /.local/bin: $PATH "
2020-06-10 14:41:28 +03:00
$CC --version
for args in " ${ ARGS [@] } " ; do
SECONDS = 0
info " Checking build with $args "
2020-06-20 01:44:09 +03:00
if ! AR = " $AR " CC = " $CC " CXX = " $CXX " CFLAGS = "-Werror" CXXFLAGS = "-Werror" meson -Dtests= unsafe -Dslow-tests= true --werror $args build; then
2020-06-11 14:18:07 +03:00
fatal " meson failed with $args "
2020-06-10 14:41:28 +03:00
fi
2020-06-11 16:00:15 +03:00
ninja --version
2020-06-10 14:41:28 +03:00
if ! ninja -C build; then
2020-06-11 14:18:07 +03:00
fatal " ninja failed with $args "
2020-06-10 14:41:28 +03:00
fi
git clean -dxf
success " Build with $args passed in $SECONDS seconds "
done