From dc9b7a15c03238f11664f5ab1e13a1288e9ad2d5 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Wed, 29 Jan 2025 18:42:25 +0400 Subject: ci(fedora41): split install prerequisites and build IWYU into separate phases It improves parallelization and speeds up the build by reusing cached layers. --- .gitlab/ci/docker/fedora41/Dockerfile | 15 +++++++++++---- .gitlab/ci/docker/fedora41/build_iwyu.sh | 25 +++++++++++++++++++++++++ .gitlab/ci/docker/fedora41/install_iwyu.sh | 28 ---------------------------- 3 files changed, 36 insertions(+), 32 deletions(-) create mode 100755 .gitlab/ci/docker/fedora41/build_iwyu.sh delete mode 100755 .gitlab/ci/docker/fedora41/install_iwyu.sh diff --git a/.gitlab/ci/docker/fedora41/Dockerfile b/.gitlab/ci/docker/fedora41/Dockerfile index ba0718c..40fafc3 100644 --- a/.gitlab/ci/docker/fedora41/Dockerfile +++ b/.gitlab/ci/docker/fedora41/Dockerfile @@ -37,16 +37,23 @@ RUN --mount=type=bind,source=dnf.conf,target=/etc/dnf/dnf.conf \ sh /root/install_rvm.sh -FROM ${BASE_IMAGE} AS iwyu-build +FROM ${BASE_IMAGE} AS iwyu-build-env LABEL maintainer="Kyle Edwards " - +# Pre-install prerequisites to build IWYU. RUN --mount=type=bind,source=dnf.conf,target=/etc/dnf/dnf.conf \ - --mount=type=bind,source=install_iwyu.sh,target=/root/install_iwyu.sh \ --mount=type=bind,source=iwyu_packages.lst,target=/root/iwyu_packages.lst \ --mount=type=cache,from=dnf-cache,source=/var/cache/libdnf5,target=/var/cache/libdnf5,sharing=private \ --mount=type=tmpfs,target=/var/log \ --mount=type=tmpfs,target=/tmp \ - sh /root/install_iwyu.sh + dnf install -y $(grep '^[^#]\+$' /root/iwyu_packages.lst) + + +FROM iwyu-build-env AS iwyu-build +LABEL maintainer="Kyle Edwards " +# Build IWYU. +RUN --mount=type=bind,source=build_iwyu.sh,target=/root/build_iwyu.sh \ + --mount=type=tmpfs,target=/tmp \ + sh /root/build_iwyu.sh FROM ${BASE_IMAGE} AS p4-dl diff --git a/.gitlab/ci/docker/fedora41/build_iwyu.sh b/.gitlab/ci/docker/fedora41/build_iwyu.sh new file mode 100755 index 0000000..ae9d306 --- /dev/null +++ b/.gitlab/ci/docker/fedora41/build_iwyu.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +set -e + +cd /root +git clone "https://github.com/include-what-you-use/include-what-you-use.git" +cd include-what-you-use +readonly llvm_full_version="$( clang --version | head -n1 | cut -d' ' -f3 )" +readonly llvm_version="$( echo "$llvm_full_version" | cut -d. -f-1 )" +git checkout "clang_$llvm_version" +mkdir build +cd build + +cmake -GNinja \ + -DCMAKE_BUILD_TYPE=Release \ + -DIWYU_RESOURCE_RELATIVE_TO=clang \ + -DIWYU_RESOURCE_DIR=../lib/clang/"$llvm_version" \ + -DCMAKE_INSTALL_PREFIX=/usr/local/lib/llvm-"$llvm_version" \ + .. + +cmake --build . --parallel + +DESTDIR=~/iwyu-destdir cmake --install . + +tar -C /root/iwyu-destdir -cf /root/iwyu.tar . diff --git a/.gitlab/ci/docker/fedora41/install_iwyu.sh b/.gitlab/ci/docker/fedora41/install_iwyu.sh deleted file mode 100755 index 5f629e6..0000000 --- a/.gitlab/ci/docker/fedora41/install_iwyu.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -set -e - -# Install development tools. -dnf install -y $(grep '^[^#]\+$' /root/iwyu_packages.lst) - -cd /root -git clone "https://github.com/include-what-you-use/include-what-you-use.git" -cd include-what-you-use -readonly llvm_full_version="$( clang --version | head -n1 | cut -d' ' -f3 )" -readonly llvm_version="$( echo "$llvm_full_version" | cut -d. -f-1 )" -git checkout "clang_$llvm_version" -mkdir build -cd build - -cmake -GNinja \ - -DCMAKE_BUILD_TYPE=Release \ - -DIWYU_RESOURCE_RELATIVE_TO=clang \ - -DIWYU_RESOURCE_DIR=../lib/clang/"$llvm_version" \ - -DCMAKE_INSTALL_PREFIX=/usr/local/lib/llvm-"$llvm_version" \ - .. - -cmake --build . --parallel - -DESTDIR=~/iwyu-destdir cmake --install . - -tar -C /root/iwyu-destdir -cf /root/iwyu.tar . -- cgit v0.12