]>
Commit | Line | Data |
---|---|---|
aab86b12 FS |
1 | #!/bin/bash |
2 | ||
0664249f | 3 | set -ex |
aab86b12 FS |
4 | |
5 | info() { echo -e "\033[33;1m$1\033[0m"; } | |
0664249f | 6 | fatal() { echo >&2 -e "\033[31;1m$1\033[0m"; exit 1; } |
aab86b12 FS |
7 | success() { echo >&2 -e "\033[32;1m$1\033[0m"; } |
8 | ||
9 | ARGS=( | |
10 | "--optimization=0" | |
11 | "--optimization=2" | |
12 | "--optimization=3" | |
13 | "--optimization=s" | |
14 | "-Db_lto=true" | |
15 | "-Db_ndebug=true" | |
16 | ) | |
17 | PACKAGES=( | |
18 | cryptsetup-bin | |
35cd3db4 FS |
19 | expect |
20 | fdisk | |
aab86b12 FS |
21 | gettext |
22 | iptables-dev | |
23 | iputils-ping | |
24 | isc-dhcp-client | |
25 | itstool | |
26 | kbd | |
27 | libblkid-dev | |
28 | libcap-dev | |
29 | libcurl4-gnutls-dev | |
35cd3db4 | 30 | libfdisk-dev |
aab86b12 FS |
31 | libgpg-error-dev |
32 | liblz4-dev | |
33 | liblzma-dev | |
34 | libmicrohttpd-dev | |
35 | libmount-dev | |
35cd3db4 FS |
36 | libp11-kit-dev |
37 | libpwquality-dev | |
aab86b12 | 38 | libqrencode-dev |
35cd3db4 | 39 | libssl-dev |
aab86b12 | 40 | libxkbcommon-dev |
35cd3db4 | 41 | libzstd-dev |
aab86b12 FS |
42 | mount |
43 | net-tools | |
aab86b12 FS |
44 | perl |
45 | python-lxml | |
46 | python3-evdev | |
47 | python3-lxml | |
48 | python3-pip | |
49 | python3-pyparsing | |
50 | python3-setuptools | |
51 | quota | |
52 | strace | |
53 | unifont | |
aab86b12 | 54 | util-linux |
35cd3db4 | 55 | zstd |
aab86b12 | 56 | ) |
0664249f FS |
57 | COMPILER="${COMPILER:?}" |
58 | COMPILER_VERSION="${COMPILER_VERSION:?}" | |
aab86b12 FS |
59 | RELEASE="$(lsb_release -cs)" |
60 | ||
61 | bash -c "echo 'deb-src http://archive.ubuntu.com/ubuntu/ $RELEASE main restricted universe multiverse' >>/etc/apt/sources.list" | |
62 | ||
0664249f FS |
63 | # Note: As we use postfixed clang/gcc binaries, we need to override $AR |
64 | # as well, otherwise meson falls back to ar from binutils which | |
65 | # doesn't work with LTO | |
66 | if [[ "$COMPILER" == clang ]]; then | |
67 | CC="clang-$COMPILER_VERSION" | |
68 | CXX="clang++-$COMPILER_VERSION" | |
69 | AR="llvm-ar-$COMPILER_VERSION" | |
70 | # Latest LLVM stack deb packages provided by https://apt.llvm.org/ | |
71 | # Following snippet was borrowed from https://apt.llvm.org/llvm.sh | |
72 | wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - | |
73 | add-apt-repository -y "deb http://apt.llvm.org/$RELEASE/ llvm-toolchain-$RELEASE-$COMPILER_VERSION main" | |
74 | apt-get -y update | |
75 | apt-get -y install 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 | apt-get -y update | |
84 | sudo apt-get -y install gcc-$COMPILER_VERSION | |
85 | else | |
86 | fatal "Unknown compiler: $COMPILER" | |
87 | fi | |
88 | ||
35cd3db4 FS |
89 | # PPA with some newer build dependencies (like zstd) |
90 | add-apt-repository -y ppa:upstream-systemd-ci/systemd-ci | |
0664249f FS |
91 | apt-get -y build-dep systemd |
92 | apt-get -y install "${PACKAGES[@]}" | |
93 | # Install latest meson and ninja form pip, since the distro versions don't | |
94 | # support all the features we need (like --optimization=) | |
95 | pip3 install meson ninja | |
aab86b12 FS |
96 | |
97 | $CC --version | |
98 | ||
99 | for args in "${ARGS[@]}"; do | |
100 | SECONDS=0 | |
101 | ||
102 | info "Checking build with $args" | |
103 | if ! AR="$AR" CC="$CC" CXX="$CXX" meson --werror $args build; then | |
0664249f | 104 | fatal "meson failed with $args" |
aab86b12 FS |
105 | fi |
106 | ||
107 | if ! ninja -C build; then | |
0664249f | 108 | fatal "ninja failed with $args" |
aab86b12 FS |
109 | fi |
110 | ||
111 | git clean -dxf | |
112 | ||
113 | success "Build with $args passed in $SECONDS seconds" | |
114 | done |