mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
3e3a8810af
This checks that (some of) the code follows some simplicity and naming guidelines set by the tool.
105 lines
2.8 KiB
Bash
Executable File
105 lines
2.8 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() {
|
|
export CPPFLAGS="-isystem $CACHEDIR/include"
|
|
export LDFLAGS="-L $CACHEDIR/lib"
|
|
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)
|
|
|
|
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" \
|
|
-DTRACE=ON \
|
|
-DMUST_BUILD_TOXAV=ON \
|
|
-DSTRICT_ABI=ON \
|
|
-DTEST_TIMEOUT_SECONDS=120 \
|
|
-DUSE_IPV6=OFF
|
|
|
|
cd _build # pushd
|
|
make "-j$NPROC" -k install
|
|
make "-j$NPROC" test ARGS="-j50" || \
|
|
make "-j$NPROC" test ARGS="-j50 --rerun-failed" CTEST_OUTPUT_ON_FAILURE=1
|
|
cd - # popd
|
|
}
|
|
|
|
if [ "-z" "$ACTION" ]; then
|
|
"travis_script"
|
|
else
|
|
"travis_$ACTION"
|
|
fi
|