ci: add ccache support

this enables and implements full support for ccache on travis builds

fix T7126

Differential Revision: https://phab.enlightenment.org/D6605

=also includes previously-submitted patches=

ci: split out ccache config setup into separate script

this provides a more unified place to set ccache options

also enable ccache compression to cut down on cache upload/download overhead

ref D6613

ci: zero ccache stats before build and add some comments for options used

zeroing the stats before each build will provide more insight into the cache
performance for each build

ref D6621

ci: break out ccache stat printing into separate script

continue to make travis.yml more readable

ref D6622

ci: add more ccache config options to improve cache direct hits

ci: disable second cpp run for ccache

this should avoid running cpp twice for files

https://ccache.samba.org/manual.html#_the_preprocessor_mode
This commit is contained in:
Mike Blumenkrantz 2018-07-10 18:43:55 -04:00 committed by Stefan Schmidt
parent 45988ac6c0
commit 005ba93234
8 changed files with 66 additions and 7 deletions

7
.ci/ccache.conf Normal file
View File

@ -0,0 +1,7 @@
max_size = 500M
compression = true
compression_level = 1
sloppiness = time_macros,include_file_mtime,include_file_ctime,file_macro
run_second_cpp = false
hash_dir = false

9
.ci/ci-ccache-stats.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
set -e
if [ "$DISTRO" != "" ] ; then
docker exec $(cat $HOME/cid) ccache -s
else
ccache -s
fi

View File

@ -49,7 +49,10 @@ if [ "$DISTRO" != "" ] ; then
if [ "$1" = "release-ready" ]; then if [ "$1" = "release-ready" ]; then
OPTS="$OPTS $RELEASE_READY_LINUX_COPTS" OPTS="$OPTS $RELEASE_READY_LINUX_COPTS"
fi fi
docker run --env MAKEFLAGS="-j5" --env EIO_MONITOR_POLL=1 -v `pwd`:/src -w /src stefanschmidt1/ci-support-files:$DISTRO ./autogen.sh $OPTS docker exec $(cat $HOME/cid) sh -c 'rm -f ~/.ccache/ccache.conf'
docker exec --env MAKEFLAGS="-j5" --env EIO_MONITOR_POLL=1 --env CC="ccache gcc" \
--env CXX="ccache g++" --env CFLAGS="-fdirectives-only" --env CXXFLAGS="-fdirectives-only" \
$(cat $HOME/cid) ./autogen.sh $OPTS
else else
OSX_COPTS="--disable-cxx-bindings" OSX_COPTS="--disable-cxx-bindings"
@ -57,11 +60,13 @@ else
mkdir -p ~/Library/LaunchAgents mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/d-bus/*.plist ~/Library/LaunchAgents ln -sfv /usr/local/opt/d-bus/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/org.freedesktop.dbus-session.plist launchctl load ~/Library/LaunchAgents/org.freedesktop.dbus-session.plist
export PATH="$(brew --prefix gettext)/bin:$PATH" export PATH="/usr/local/opt/ccache/libexec:$(brew --prefix gettext)/bin:$PATH"
export CFLAGS="-I/usr/local/opt/openssl/include $CFLAGS" export CFLAGS="-I/usr/local/opt/openssl/include -frewrite-includes $CFLAGS"
export LDFLAGS="-L/usr/local/opt/openssl/lib $LDFLAGS"
export LDFLAGS="-L/usr/local/opt/openssl/lib $LDFLAGS" export LDFLAGS="-L/usr/local/opt/openssl/lib $LDFLAGS"
# Normal build test of all targets # Normal build test of all targets
rm -f ~/.ccache/ccache.conf
./autogen.sh $OSX_COPTS ./autogen.sh $OSX_COPTS
fi fi

View File

@ -7,7 +7,10 @@ if [ "$1" != "release-ready" ] ; then
fi fi
if [ "$DISTRO" != "" ] ; then if [ "$DISTRO" != "" ] ; then
docker exec --env MAKEFLAGS="-j5" --env EIO_MONITOR_POLL=1 $(cat $HOME/cid) make distcheck docker exec --env MAKEFLAGS="-j5" --env EIO_MONITOR_POLL=1 --env CC="ccache gcc" \
--env CXX="ccache g++" \
--env CFLAGS="-fdirectives-only" --env CXXFLAGS="-fdirectives-only" \
$(cat $HOME/cid) make distcheck
else else
export PATH="/usr/local/opt/ccache/libexec:$(brew --prefix gettext)/bin:$PATH" export PATH="/usr/local/opt/ccache/libexec:$(brew --prefix gettext)/bin:$PATH"
make make

View File

@ -2,4 +2,4 @@
brew update brew update
brew unlink python brew unlink python
brew install gettext check bullet dbus fontconfig freetype fribidi gst-plugins-good gstreamer luajit openssl webp libsndfile glib libspectre libraw librsvg poppler lz4 pulseaudio brew install gettext check bullet dbus fontconfig freetype fribidi gst-plugins-good gstreamer luajit openssl webp libsndfile glib libspectre libraw librsvg poppler lz4 pulseaudio ccache

12
.ci/ci-setup-ccache.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
set -e
if [ "$DISTRO" != "" ] ; then
docker exec $(cat $HOME/cid) sh -c ".ci/docker-ccache-setup.sh $1"
docker exec $(cat $HOME/cid) ccache -pz
else
cp .ci/ccache.conf ~/.ccache
ccache -o base_dir="$(pwd)"
ccache -pz
fi

11
.ci/docker-ccache-setup.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
CI_BUILD_TYPE="$1"
cp .ci/ccache.conf ~/.ccache
if [ "$1" = "release-ready" ] ; then
ccache -o base_dir="$(pwd)/$(grep '^PACKAGE_STRING' config.log|cut -d\' -f2|tr ' ' -)"
else
ccache -o base_dir=$(pwd)
fi

View File

@ -1,5 +1,5 @@
language: c language: c
cache: ccache
sudo: required sudo: required
dist: trusty dist: trusty
@ -11,6 +11,8 @@ env:
global: global:
- MAKEFLAGS="-j5" - MAKEFLAGS="-j5"
- EIO_MONITOR_POLL=1 - EIO_MONITOR_POLL=1
- CC="ccache gcc"
- CXX="ccache g++"
matrix: matrix:
- -
- DISTRO=Ubuntu1804 - DISTRO=Ubuntu1804
@ -70,12 +72,15 @@ before_script:
- | - |
if [[ "$TRAVIS_OS_NAME" == "linux" ]] ; then if [[ "$TRAVIS_OS_NAME" == "linux" ]] ; then
docker version docker version
docker run --cidfile $HOME/cid -t -d -v `pwd`:/src -w /src stefanschmidt1/ci-support-files:$DISTRO bash docker run --cidfile $HOME/cid -t -d -v `pwd`:/src -v $HOME/.ccache:/root/.ccache -w /src stefanschmidt1/ci-support-files:$DISTRO bash
cat $HOME/cid cat $HOME/cid
fi fi
- .ci/ci-ccache-stats.sh
script: script:
- .ci/ci-configure.sh "$CI_BUILD_TYPE" - .ci/ci-configure.sh "$CI_BUILD_TYPE"
- .ci/ci-setup-ccache.sh "$CI_BUILD_TYPE"
- .ci/ci-make.sh "$CI_BUILD_TYPE" - .ci/ci-make.sh "$CI_BUILD_TYPE"
- .ci/ci-make-checkbuild.sh "$CI_BUILD_TYPE" - .ci/ci-make-checkbuild.sh "$CI_BUILD_TYPE"
- .ci/ci-make-examples.sh "$CI_BUILD_TYPE" - .ci/ci-make-examples.sh "$CI_BUILD_TYPE"
@ -91,6 +96,13 @@ script:
elif [[ "$CI_BUILD_TYPE" != "release-ready" ]] ; then elif [[ "$CI_BUILD_TYPE" != "release-ready" ]] ; then
docker exec --env MAKEFLAGS="-j5" --env EIO_MONITOR_POLL=1 $(cat $HOME/cid) .ci/build-efl-app.sh docker exec --env MAKEFLAGS="-j5" --env EIO_MONITOR_POLL=1 $(cat $HOME/cid) .ci/build-efl-app.sh
fi fi
before_cache:
- .ci/ci-ccache-stats.sh
- |
if [[ "$TRAVIS_OS_NAME" == "linux" ]] ; then
sudo chown travis:travis $HOME/.ccache
else
fi
after_success: after_success:
- | - |