2020-03-07 05:23:20 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2021-05-12 22:42:37 +08:00
|
|
|
if test -f /etc/debian_version; then
|
|
|
|
CCACHE_PATH=/usr/lib/ccache
|
|
|
|
else
|
|
|
|
CCACHE_PATH=/usr/lib64/ccache
|
|
|
|
fi
|
|
|
|
|
2020-02-12 07:44:56 +08:00
|
|
|
# Common setup among container builds before we get to building code.
|
|
|
|
|
2020-03-07 05:23:20 +08:00
|
|
|
export CCACHE_COMPILERCHECK=content
|
|
|
|
export CCACHE_COMPRESS=true
|
2022-03-17 22:09:18 +08:00
|
|
|
export CCACHE_DIR=/cache/$CI_PROJECT_NAME/ccache
|
2021-05-12 22:42:37 +08:00
|
|
|
export PATH=$CCACHE_PATH:$PATH
|
2020-03-07 05:23:20 +08:00
|
|
|
|
2020-03-12 02:11:19 +08:00
|
|
|
# CMake ignores $PATH, so we have to force CC/GCC to the ccache versions.
|
2021-05-12 22:42:37 +08:00
|
|
|
export CC="${CCACHE_PATH}/gcc"
|
|
|
|
export CXX="${CCACHE_PATH}/g++"
|
2020-03-12 02:11:19 +08:00
|
|
|
|
2022-07-27 23:38:09 +08:00
|
|
|
# When not using the mold linker (e.g. unsupported architecture), force
|
|
|
|
# linkers to gold, since it's so much faster for building. We can't use
|
2020-08-14 05:21:50 +08:00
|
|
|
# lld because we're on old debian and it's buggy. ming fails meson builds
|
|
|
|
# with it with "meson.build:21:0: ERROR: Unable to determine dynamic linker"
|
|
|
|
find /usr/bin -name \*-ld -o -name ld | \
|
|
|
|
grep -v mingw | \
|
|
|
|
xargs -n 1 -I '{}' ln -sf '{}.gold' '{}'
|
|
|
|
|
2020-03-07 05:23:20 +08:00
|
|
|
ccache --show-stats
|
2020-02-12 07:44:56 +08:00
|
|
|
|
|
|
|
# Make a wrapper script for ninja to always include the -j flags
|
2022-07-16 22:40:04 +08:00
|
|
|
{
|
|
|
|
echo '#!/bin/sh -x'
|
|
|
|
# shellcheck disable=SC2016
|
|
|
|
echo '/usr/bin/ninja -j${FDO_CI_CONCURRENT:-4} "$@"'
|
|
|
|
} > /usr/local/bin/ninja
|
2020-02-12 07:44:56 +08:00
|
|
|
chmod +x /usr/local/bin/ninja
|
|
|
|
|
|
|
|
# Set MAKEFLAGS so that all make invocations in container builds include the
|
|
|
|
# flags (doesn't apply to non-container builds, but we don't run make there)
|
2020-06-27 01:59:41 +08:00
|
|
|
export MAKEFLAGS="-j${FDO_CI_CONCURRENT:-4}"
|
2022-07-20 21:21:37 +08:00
|
|
|
|
|
|
|
# make wget to try more than once, when download fails or timeout
|
|
|
|
echo -e "retry_connrefused = on\n" \
|
|
|
|
"read_timeout = 300\n" \
|
|
|
|
"tries = 4\n" \
|
|
|
|
"wait_retry = 32" >> /etc/wgetrc
|