Skip to content

Commit

Permalink
Use ccache with cmake on travis.
Browse files Browse the repository at this point in the history
This replaces the custom python script which manipulated various files' mtime with ccache for allowing cmake builds to not need full recompiles every travis run.
  • Loading branch information
Pentarctagon committed Feb 17, 2018
1 parent 72a80fe commit ee1a56a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 84 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Expand Up @@ -5,6 +5,7 @@ services:
- docker

cache:
ccache: true
directories:
- build-cache

Expand Down Expand Up @@ -62,12 +63,12 @@ script:
./utils/travis/check_utf8.sh;
./utils/travis/utf8_bom_dog.sh;
"$CXX" --version;
scons wesnoth wesnothd campaignd boost_unit_tests build=release ctool="$CC" cxxtool="$CXX" --debug=time extra_flags_config="-pipe" extra_flags_release="$EXTRA_FLAGS_RELEASE" strict=true cxx_std="$CXXSTD" nls="$NLS" jobs=2;
scons wesnoth wesnothd campaignd boost_unit_tests build=release ctool="$CC" cxxtool="$CXX" --debug=time extra_flags_config="-pipe" extra_flags_release="$EXTRA_FLAGS_RELEASE" strict=true cxx_std="$CXXSTD" nls="$NLS" jobs=2 enable_lto=false;
else
export DISPLAY=:99.0;
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1024x768x24;

docker run -v "$PWD"/build-cache:/home/wesnoth-travis/build wesnoth-repo:16.04 bash -c './docker_run.sh "$@"' bash "$NLS" "$TOOL" "$CC" "$CXX" "$CXXSTD" "$EXTRA_FLAGS_RELEASE" "$WML_TESTS" "$WML_TEST_TIME" "$PLAY_TEST" "$MP_TEST" "$BOOST_TEST";
docker run -v "$PWD"/build-cache:/home/wesnoth-travis/build -v "$HOME"/.ccache:/root/.ccache wesnoth-repo:16.04 bash -c './docker_run.sh "$@"' bash "$NLS" "$TOOL" "$CC" "$CXX" "$CXXSTD" "$EXTRA_FLAGS_RELEASE" "$WML_TESTS" "$WML_TEST_TIME" "$PLAY_TEST" "$MP_TEST" "$BOOST_TEST";
fi

notifications:
Expand Down
71 changes: 0 additions & 71 deletions cmake_mtime_crc.py

This file was deleted.

2 changes: 2 additions & 0 deletions docker/Dockerfile-travis
Expand Up @@ -2,5 +2,7 @@ FROM wesnoth/wesnoth:16.04

COPY ./ /home/wesnoth-travis/

RUN apt install -y -qq ccache

WORKDIR /home/wesnoth-travis

20 changes: 9 additions & 11 deletions docker_run.sh
Expand Up @@ -49,19 +49,13 @@ if [ "$NLS" == "true" ]; then
else
# if not doing the translations, build wesnoth, wesnothd, campaignd, boost_unit_tests
if [ "$TOOL" == "cmake" ]; then
# softlink to build/ for cmake, since that's where the docker mount point is
cd src/
ln -s ../build CMakeFiles
cd ..
# run cmake separately so config.h will be seen by the md5 script
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_GAME=true -DENABLE_SERVER=true -DENABLE_CAMPAIGN_SERVER=true -DENABLE_TESTS=true -DENABLE_NLS=false -DEXTRA_FLAGS_CONFIG="-pipe" -DEXTRA_FLAGS_RELEASE="$EXTRA_FLAGS_RELEASE" -DENABLE_STRICT_COMPILATION="$STRICT"
# run manual md5 file tracking/mtime modification script for cmake
python3 cmake_mtime_crc.py

make VERBOSE=1 -j2
# set ccache configurations
echo "max_size = 200M" > $HOME/.ccache/ccache.conf
echo "compiler_check = content" >> $HOME/.ccache/ccache.conf

cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_GAME=true -DENABLE_SERVER=true -DENABLE_CAMPAIGN_SERVER=true -DENABLE_TESTS=true -DENABLE_NLS=false -DEXTRA_FLAGS_CONFIG="-pipe" -DEXTRA_FLAGS_RELEASE="$EXTRA_FLAGS_RELEASE" -DENABLE_STRICT_COMPILATION="$STRICT" -DENABLE_LTO=false -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache && make VERBOSE=1 -j2
else
scons wesnoth wesnothd campaignd boost_unit_tests build=release ctool=$CC cxxtool=$CXX --debug=time extra_flags_config="-pipe" extra_flags_release="$EXTRA_FLAGS_RELEASE" strict="$STRICT" cxx_std=$CXXSTD nls=false jobs=2
scons wesnoth wesnothd campaignd boost_unit_tests build=release ctool=$CC cxxtool=$CXX --debug=time extra_flags_config="-pipe" extra_flags_release="$EXTRA_FLAGS_RELEASE" strict="$STRICT" cxx_std=$CXXSTD nls=false jobs=2 enable_lto=false
fi

# check if the build was successful
Expand All @@ -78,6 +72,7 @@ else
./run_wml_tests -g -v -c -t "$WML_TEST_TIME"
RET=$?
if [ $RET != 0 ]; then
echo "WML tests failed!"
EXIT_VAL=$RET
fi
fi
Expand All @@ -87,6 +82,7 @@ else
./utils/travis/play_test_executor.sh
RET=$?
if [ $RET != 0 ]; then
echo "Play tests failed!"
EXIT_VAL=$RET
fi
fi
Expand All @@ -96,6 +92,7 @@ else
./utils/travis/mp_test_executor.sh
RET=$?
if [ $RET != 0 ]; then
echo "MP tests failed!"
EXIT_VAL=$RET
fi
fi
Expand All @@ -105,6 +102,7 @@ else
./utils/travis/test_executor.sh
RET=$?
if [ $RET != 0 ]; then
echo "Boost tests failed!"
EXIT_VAL=$RET
fi
fi
Expand Down

0 comments on commit ee1a56a

Please sign in to comment.