2020-04-08 23:06:40 +08:00
|
|
|
#!/bin/bash
|
2018-06-25 06:56:07 +08:00
|
|
|
|
|
|
|
ACTION="$1"
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
CACHEDIR="$HOME/cache"
|
|
|
|
NPROC=`nproc`
|
|
|
|
ASTYLE="$CACHEDIR/astyle/build/gcc/bin/astyle"
|
2020-02-28 08:00:00 +08:00
|
|
|
ASTYLE_VERSION=3.1
|
2020-04-08 23:06:40 +08:00
|
|
|
TRAVIS_TOOL="https://raw.githubusercontent.com/TokTok/ci-tools/master/bin/travis-haskell"
|
2018-08-07 02:49:02 +08:00
|
|
|
|
2018-06-25 06:56:07 +08:00
|
|
|
travis_install() {
|
2020-04-08 23:06:40 +08:00
|
|
|
bash <(curl -s "$TRAVIS_TOOL") download
|
|
|
|
travis-haskell download TokTok/hs-tokstyle tokstyle "$HOME/.local"
|
2018-08-07 02:49:02 +08:00
|
|
|
|
2018-06-25 06:56:07 +08:00
|
|
|
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).
|
2020-02-28 08:00:00 +08:00
|
|
|
([ -f "$ASTYLE" ] && "$ASTYLE" --version | grep "$ASTYLE_VERSION" >/dev/null) || {
|
|
|
|
wget -O ../astyle.tar.gz "https://deb.debian.org/debian/pool/main/a/astyle/astyle_$ASTYLE_VERSION.orig.tar.gz"
|
2018-06-25 06:56:07 +08:00
|
|
|
tar -xf ../astyle.tar.gz -C "$CACHEDIR"
|
2020-02-28 08:00:00 +08:00
|
|
|
make -C "$CACHEDIR/astyle/build/gcc" clean
|
2018-06-25 06:56:07 +08:00
|
|
|
make -C "$CACHEDIR/astyle/build/gcc" "-j$NPROC"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-17 09:18:04 +08:00
|
|
|
run_static_analysis() {
|
2018-08-27 23:51:41 +08:00
|
|
|
pylint -E other/analysis/check_recursion
|
|
|
|
|
2018-07-17 09:18:04 +08:00
|
|
|
export CPPFLAGS="-isystem $CACHEDIR/include"
|
2020-04-08 23:06:40 +08:00
|
|
|
export LDFLAGS="-L$CACHEDIR/lib"
|
2018-08-27 23:51:41 +08:00
|
|
|
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
|
2018-07-17 09:18:04 +08:00
|
|
|
other/analysis/run-clang
|
|
|
|
other/analysis/run-clang-analyze
|
|
|
|
}
|
|
|
|
|
2018-06-25 06:56:07 +08:00
|
|
|
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
|
|
|
|
|
2020-02-28 08:00:00 +08:00
|
|
|
"$ASTYLE" --version
|
2018-07-13 04:56:22 +08:00
|
|
|
other/astyle/format-source . "$ASTYLE"
|
|
|
|
|
2018-08-07 02:49:02 +08:00
|
|
|
echo "Running TokTok style checker"
|
|
|
|
"$HOME/.local/bin/check-cimple"
|
|
|
|
|
2018-07-17 09:18:04 +08:00
|
|
|
# Use () to run in a separate process so the exports are local.
|
|
|
|
(run_static_analysis)
|
|
|
|
|
2018-10-06 13:22:43 +08:00
|
|
|
other/analysis/check_logger_levels
|
|
|
|
|
2020-03-03 06:13:31 +08:00
|
|
|
cmake -B_build -H. -GNinja \
|
2018-06-25 06:56:07 +08:00
|
|
|
-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" \
|
2018-10-03 19:49:17 +08:00
|
|
|
-DMIN_LOGGER_LEVEL=TRACE \
|
2018-06-25 06:56:07 +08:00
|
|
|
-DMUST_BUILD_TOXAV=ON \
|
2020-04-29 20:09:34 +08:00
|
|
|
-DNON_HERMETIC_TESTS=ON \
|
2018-06-25 06:56:07 +08:00
|
|
|
-DSTRICT_ABI=ON \
|
|
|
|
-DTEST_TIMEOUT_SECONDS=120 \
|
2018-10-07 02:03:52 +08:00
|
|
|
-DUSE_IPV6=OFF \
|
|
|
|
-DAUTOTEST=ON
|
2018-06-25 06:56:07 +08:00
|
|
|
|
2020-03-03 06:13:31 +08:00
|
|
|
cmake --build _build --parallel "$NPROC" --target install -- -k 0
|
|
|
|
|
2018-06-25 06:56:07 +08:00
|
|
|
cd _build # pushd
|
2018-08-22 01:40:39 +08:00
|
|
|
ctest -j50 --output-on-failure || \
|
|
|
|
ctest -j50 --output-on-failure --rerun-failed
|
2018-06-25 06:56:07 +08:00
|
|
|
cd - # popd
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "-z" "$ACTION" ]; then
|
|
|
|
"travis_script"
|
|
|
|
else
|
|
|
|
"travis_$ACTION"
|
|
|
|
fi
|