Merge pull request #19 from mbitsnbites/feature/add_a_build_test

Add a test that builds Bullet Physics using BuildCache
This commit is contained in:
mbitsnbites
2019-02-06 09:46:45 +01:00
committed by GitHub
2 changed files with 90 additions and 1 deletions
+4 -1
View File
@@ -19,6 +19,7 @@ matrix:
- cmake --build .
- CTEST_OUTPUT_ON_FAILURE=TRUE ctest
- ../test_scripts/run_lock_file_stresstest.sh
- ../test_scripts/build_with_buildcache.sh
# macOS clang
- os: osx
@@ -33,6 +34,7 @@ matrix:
- cmake --build .
- CTEST_OUTPUT_ON_FAILURE=TRUE ctest
- ../test_scripts/run_lock_file_stresstest.sh
- ../test_scripts/build_with_buildcache.sh
# Windows MSVC 2017
- os: windows
@@ -50,4 +52,5 @@ matrix:
ninja'
- CTEST_OUTPUT_ON_FAILURE=TRUE ninja test
- ../test_scripts/run_lock_file_stresstest.sh
# TODO(m): It would be nice to get this working...
#- cmd.exe /C '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64 && "C:\Program Files\Git\bin\sh.exe" ../test_scripts/build_with_buildcache.sh'
+86
View File
@@ -0,0 +1,86 @@
#!/bin/bash
# Check if we're running on Windows (this is mostly a trick to get the script
# working on the Travis-CI Windows slaves that run Git bash).
function is_windows() {
if [ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]; then
return 0
fi
return 1
}
function cleanup() {
[[ ! -z "${PROJDIR}" ]] && rm -rf "${PROJDIR}"
[[ ! -z "${BUILDCACHE_DIR}" ]] && rm -rf "${BUILDCACHE_DIR}"
}
# Treat errors with exit code 1.
function trap_handler() {
MYSELF="$0"
LASTLINE="$1"
LASTERR="$2"
echo "ERROR: ${MYSELF}: line ${LASTLINE}: exit status of last command: ${LASTERR}"
cleanup
exit "${LASTERR}"
}
trap 'trap_handler ${LINENO} ${$?}' ERR INT TERM
# Set up a working environment for Windows if needed.
EXESUFFIX=
if is_windows; then
EXESUFFIX=".exe"
fi
# Note: This script is expected to be run from the BuildCache build folder.
BUILDCACHEDIR="$( realpath "$(pwd)" )"
# Install BuildCache and symlinks to BuildCache for common compilers.
BUILDCACHEEXE="${BUILDCACHEDIR}/buildcache${EXESUFFIX}"
echo "Buildcache executable: ${BUILDCACHEEXE}"
SYMLINKSDIR="${BUILDCACHEDIR}/symlinks"
echo "Install symlinks in: ${SYMLINKSDIR}"
rm -rf "${SYMLINKSDIR}" ; mkdir -p "${SYMLINKSDIR}"
ln -s "${BUILDCACHEEXE}" "${SYMLINKSDIR}/cc${EXESUFFIX}"
ln -s "${BUILDCACHEEXE}" "${SYMLINKSDIR}/c++${EXESUFFIX}"
ln -s "${BUILDCACHEEXE}" "${SYMLINKSDIR}/gcc${EXESUFFIX}"
ln -s "${BUILDCACHEEXE}" "${SYMLINKSDIR}/g++${EXESUFFIX}"
ln -s "${BUILDCACHEEXE}" "${SYMLINKSDIR}/clang${EXESUFFIX}"
ln -s "${BUILDCACHEEXE}" "${SYMLINKSDIR}/clang++${EXESUFFIX}"
ln -s "${BUILDCACHEEXE}" "${SYMLINKSDIR}/cl${EXESUFFIX}"
export PATH="${SYMLINKSDIR}:${BUILDCACHEDIR}:${PATH}"
# Configure BuildCache.
export BUILDCACHE_DIR=/tmp/.buildcache-$$
rm -rf "${BUILDCACHE_DIR}" ; mkdir -p "${BUILDCACHE_DIR}"
export BUILDCACHE_DEBUG=2
# Clone the project.
PROJDIR="/tmp/proj-$$"
SRCDIR="${PROJDIR}"
BUILDDIR="${PROJDIR}/out"
rm -rf "${PROJDIR}"
git clone --branch 2.88 --depth 1 https://github.com/bulletphysics/bullet3.git "${PROJDIR}"
echo "======== First build (cold cache) ========"
buildcache -C
cd "${PROJDIR}"
rm -rf "${BUILDDIR}" ; mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release "${SRCDIR}"
time ninja
buildcache -s
echo "======== Second build (warm cache) ========"
cd "${PROJDIR}"
rm -rf "${BUILDDIR}" ; mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release "${SRCDIR}"
time ninja
buildcache -s
echo "======== Cleaning up ========"
cleanup