mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-27 18:28:35 +00:00
Use ccache with cmake on travis.
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.
This commit is contained in:
parent
72a80fed5b
commit
ee1a56a04a
@ -5,6 +5,7 @@ services:
|
||||
- docker
|
||||
|
||||
cache:
|
||||
ccache: true
|
||||
directories:
|
||||
- build-cache
|
||||
|
||||
@ -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:
|
||||
|
@ -1,71 +0,0 @@
|
||||
import os
|
||||
from time import time
|
||||
from zlib import crc32
|
||||
|
||||
# #
|
||||
# Functions
|
||||
# #
|
||||
|
||||
# get the CRC of a file's contents
|
||||
def getCRC32(file):
|
||||
src_file = open(file, "r", encoding="utf-8")
|
||||
file_contents = src_file.read()
|
||||
src_file.close()
|
||||
|
||||
return crc32(file_contents.encode("utf8"))
|
||||
|
||||
# recursively get all files in all subdirectories
|
||||
def getAllFiles(start):
|
||||
file_list = []
|
||||
|
||||
for root, _, files in os.walk(start):
|
||||
for file in files:
|
||||
file_list.append(root+"/"+file)
|
||||
|
||||
return file_list
|
||||
|
||||
# #
|
||||
# Variables
|
||||
# #
|
||||
today = time()
|
||||
yesterday = time() - (24*60*60)
|
||||
mtime_file = "build/cmake_mtime_crc.txt"
|
||||
|
||||
# #
|
||||
# Run
|
||||
# #
|
||||
file_list = getAllFiles("src")
|
||||
|
||||
# get the current CRC all relevant files in src/, and set their mtime to yesterday
|
||||
crc_dict_curr = {}
|
||||
for file in file_list:
|
||||
os.utime(file, (yesterday, yesterday))
|
||||
if (file.endswith(".cpp") or file.endswith(".hpp") or file.endswith(".tpp") or file.endswith(".c") or file.endswith(".h")) and "CMakeFiles" not in file:
|
||||
crc_dict_curr.update({file : getCRC32(file)})
|
||||
|
||||
# if there's an existing stored list of CRCs, read that in
|
||||
if os.path.isfile(mtime_file):
|
||||
readfile = open(mtime_file, "r", encoding="utf-8")
|
||||
crc_dict_prev = {}
|
||||
|
||||
for line in readfile:
|
||||
line_list = line.strip().split(":")
|
||||
crc_dict_prev.update({line_list[0] : int(line_list[1])})
|
||||
readfile.close()
|
||||
|
||||
# compare file CRCs between the set of CRCs from the previous run and the current run
|
||||
# if the file has changed, or is brand new, set its mtime to today so that cmake will know to recompile it
|
||||
for key, value in crc_dict_curr.items():
|
||||
if key in crc_dict_prev:
|
||||
if value != crc_dict_prev[key]:
|
||||
os.utime(key, (today, today))
|
||||
else:
|
||||
os.utime(key, (today, today))
|
||||
|
||||
# write out the new set of file CRCs
|
||||
writefile = open(mtime_file, "w")
|
||||
for key, value in crc_dict_curr.items():
|
||||
writefile.write(key+":"+str(value)+"\n")
|
||||
writefile.close()
|
||||
|
||||
print("Updated cmake mtime data!")
|
@ -2,5 +2,7 @@ FROM wesnoth/wesnoth:16.04
|
||||
|
||||
COPY ./ /home/wesnoth-travis/
|
||||
|
||||
RUN apt install -y -qq ccache
|
||||
|
||||
WORKDIR /home/wesnoth-travis
|
||||
|
||||
|
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
@ -105,6 +102,7 @@ else
|
||||
./utils/travis/test_executor.sh
|
||||
RET=$?
|
||||
if [ $RET != 0 ]; then
|
||||
echo "Boost tests failed!"
|
||||
EXIT_VAL=$RET
|
||||
fi
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user