toxcore/.travis/cmake-linux
2018-10-07 22:09:54 +00:00

115 lines
3.1 KiB
Bash
Executable File

#!/bin/sh
ACTION="$1"
set -eu
CACHEDIR="$HOME/cache"
NPROC=`nproc`
ASTYLE="$CACHEDIR/astyle/build/gcc/bin/astyle"
install_tool() {
SLUG="$1"
TOOL="$2"
TARGET="$3"
VERSION=$(curl -L -s -H 'Accept: application/json' \
"https://github.com/$SLUG/releases/latest" \
| egrep -o '"v[0-9][^"]+"' \
| egrep -o '[^"]+')
URL="https://github.com/$SLUG/releases/download/$VERSION/$TOOL-x86_64-linux-$VERSION.tar.gz"
curl -L -s "$URL" | tar xzv -C "$TARGET"
}
travis_install() {
install_tool TokTok/hs-tokstyle tokstyle "$HOME/.local"
which coveralls || {
# Install cpp-coveralls to upload test coverage results.
pip install --user ndg-httpsclient urllib3[secure] cpp-coveralls
# Work around https://github.com/eddyxu/cpp-coveralls/issues/108 by manually
# installing the pyOpenSSL module and injecting it into urllib3 as per
# https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl-py2
sed -i -e '/^import sys$/a import urllib3.contrib.pyopenssl\nurllib3.contrib.pyopenssl.inject_into_urllib3()' `which coveralls`
}
# Install astyle (version in ubuntu-precise too old).
[ -f "$ASTYLE" ] || {
wget -O ../astyle.tar.gz https://deb.debian.org/debian/pool/main/a/astyle/astyle_2.06.orig.tar.gz
tar -xf ../astyle.tar.gz -C "$CACHEDIR"
make -C "$CACHEDIR/astyle/build/gcc" "-j$NPROC"
}
# Install libsodium (not in ubuntu-precise).
[ -f "$CACHEDIR/lib/libsodium.a" ] || {
git clone --depth=1 --branch=stable https://github.com/jedisct1/libsodium ../libsodium
cd ../libsodium # pushd
./autogen.sh
./configure --prefix="$CACHEDIR"
make install "-j$NPROC"
cd - # popd
}
}
run_static_analysis() {
pylint -E other/analysis/check_recursion
export CPPFLAGS="-isystem $CACHEDIR/include"
export LDFLAGS="-L $CACHEDIR/lib"
cat toxav/*.c toxcore/*.c toxencryptsave/*.c \
| clang `pkg-config --cflags libsodium opus vpx` \
-Itoxav -Itoxcore -Itoxencryptsave -S -emit-llvm -xc - -o- \
| opt -analyze -print-callgraph 2>&1 \
| other/analysis/check_recursion
other/analysis/run-clang
other/analysis/run-clang-analyze
}
travis_script() {
. ".travis/flags-$CC.sh"
add_ld_flag -Wl,-z,defs
# Make compilation error on a warning
add_flag -Werror
# Coverage flags.
add_flag -fprofile-arcs -ftest-coverage
other/astyle/format-source . "$ASTYLE"
echo "Running TokTok style checker"
"$HOME/.local/bin/check-cimple"
# Use () to run in a separate process so the exports are local.
(run_static_analysis)
other/analysis/check_logger_levels
cmake -B_build -H. \
-DCMAKE_C_FLAGS="$C_FLAGS" \
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="$LD_FLAGS" \
-DCMAKE_INSTALL_PREFIX:PATH="$PWD/_install" \
-DMIN_LOGGER_LEVEL=TRACE \
-DMUST_BUILD_TOXAV=ON \
-DSTRICT_ABI=ON \
-DTEST_TIMEOUT_SECONDS=120 \
-DUSE_IPV6=OFF \
-DAUTOTEST=ON
cd _build # pushd
make "-j$NPROC" -k install
ctest -j50 --output-on-failure || \
ctest -j50 --output-on-failure --rerun-failed
cd - # popd
}
if [ "-z" "$ACTION" ]; then
"travis_script"
else
"travis_$ACTION"
fi