Skip to content

Commit

Permalink
Configure Travis to run clang-tidy plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytheway committed Jun 19, 2019
1 parent 8f5cb00 commit 91946b2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ jobs:
osx_image: xcode10.1
compiler: clang

- env: CLANG=clang++-8 TILES=1 SOUND=1 CXXFLAGS=-Wno-unused-command-line-argument CMAKE=1 CATA_CLANG_TIDY=clang-tidy-8
- env: CLANG=clang++-8 TILES=1 SOUND=1 CXXFLAGS=-Wno-unused-command-line-argument CMAKE=1 CATA_CLANG_TIDY=plugin
name: "Clang-tidy CMake build with Tiles and Sound"
compiler: clang
addons: &clang8
apt:
packages: ["clang-8", "clang-tidy-8", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev"]
packages: ["clang-8", "libclang-8-dev", "llvm-8-dev", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev"]
sources: [*apt_sources, llvm-toolchain-xenial-8]

# Finally check the compiler variants
Expand Down
18 changes: 18 additions & 0 deletions build-scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ then
build_type=Debug
fi

cmake_extra_opts=

if [ "$CATA_CLANG_TIDY" = "plugin" ]
then
cmake_extra_opts="$cmake_extra_opts -DCATA_CLANG_TIDY_PLUGIN=ON"
# Need to specify the particular LLVM / Clang versions to use, lest it
# use the llvm-7 that comes by default on the Travis Xenial image.
cmake_extra_opts="$cmake_extra_opts -DLLVM_DIR=/usr/lib/llvm-8/lib/cmake/llvm"
cmake_extra_opts="$cmake_extra_opts -DClang_DIR=/usr/lib/llvm-8/lib/cmake/clang"
fi

mkdir build
cd build
cmake \
Expand All @@ -49,9 +60,16 @@ then
-DCMAKE_BUILD_TYPE="$build_type" \
-DTILES=${TILES:-0} \
-DSOUND=${SOUND:-0} \
$cmake_extra_opts \
..
if [ -n "$CATA_CLANG_TIDY" ]
then
if [ "$CATA_CLANG_TIDY" = "plugin" ]
then
make -j$num_jobs CataAnalyzerPlugin
CATA_CLANG_TIDY=$PWD/tools/clang-tidy-plugin/clang-tidy-plugin-support/bin/clang-tidy
fi

"$CATA_CLANG_TIDY" --version

# Run clang-tidy analysis instead of regular build & test
Expand Down
9 changes: 8 additions & 1 deletion build-scripts/clang-tidy-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,12 @@ then
exit 0
fi

plugin=build/tools/clang-tidy-plugin/libCataAnalyzerPlugin.so

set -x
"$CATA_CLANG_TIDY" "$@"
if [ -f "$plugin" ]
then
LD_PRELOAD=$plugin "$CATA_CLANG_TIDY" "$@"
else
"$CATA_CLANG_TIDY" "$@"
fi

0 comments on commit 91946b2

Please sign in to comment.