1#!/bin/sh 2 3if test -x /usr/bin/ccache; then 4 if test -f /etc/debian_version; then 5 CCACHE_PATH=/usr/lib/ccache 6 elif test -f /etc/alpine-release; then 7 CCACHE_PATH=/usr/lib/ccache/bin 8 else 9 CCACHE_PATH=/usr/lib64/ccache 10 fi 11 12 # Common setup among container builds before we get to building code. 13 14 export CCACHE_COMPILERCHECK=content 15 export CCACHE_COMPRESS=true 16 export CCACHE_DIR=/cache/$CI_PROJECT_NAME/ccache 17 export PATH=$CCACHE_PATH:$PATH 18 19 # CMake ignores $PATH, so we have to force CC/GCC to the ccache versions. 20 export CC="${CCACHE_PATH}/gcc" 21 export CXX="${CCACHE_PATH}/g++" 22 23 ccache --show-stats 24fi 25 26# When not using the mold linker (e.g. unsupported architecture), force 27# linkers to gold, since it's so much faster for building. We can't use 28# lld because we're on old debian and it's buggy. mingw fails meson builds 29# with it with "meson.build:21:0: ERROR: Unable to determine dynamic linker" 30find /usr/bin -name \*-ld -o -name ld | \ 31 grep -v mingw | \ 32 xargs -n 1 -I '{}' ln -sf '{}.gold' '{}' 33 34# Make a wrapper script for ninja to always include the -j flags 35{ 36 echo '#!/bin/sh -x' 37 # shellcheck disable=SC2016 38 echo '/usr/bin/ninja -j${FDO_CI_CONCURRENT:-4} "$@"' 39} > /usr/local/bin/ninja 40chmod +x /usr/local/bin/ninja 41 42# Set MAKEFLAGS so that all make invocations in container builds include the 43# flags (doesn't apply to non-container builds, but we don't run make there) 44export MAKEFLAGS="-j${FDO_CI_CONCURRENT:-4}" 45 46# make wget to try more than once, when download fails or timeout 47echo -e "retry_connrefused = on\n" \ 48 "read_timeout = 300\n" \ 49 "tries = 4\n" \ 50 "retry_on_host_error = on\n" \ 51 "retry_on_http_error = 429,500,502,503,504\n" \ 52 "wait_retry = 32" >> /etc/wgetrc 53