2018-05-07 01:07:34 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2023-06-06 04:37:47 +08:00
|
|
|
LOCALSTRING="local"
|
|
|
|
|
|
|
|
if [ "$3" = "$LOCALSTRING" ]; then
|
|
|
|
REGEX="/cuberite/src/\.?[^\.]"
|
|
|
|
else
|
|
|
|
REGEX="cuberite_[^/\.]+/src/\.?[^\.]"
|
|
|
|
fi
|
|
|
|
|
2018-05-07 01:07:34 +08:00
|
|
|
FIXES_FILE="tidy-fixes.yaml"
|
2023-06-06 04:37:47 +08:00
|
|
|
ARGS="-header-filter $REGEX -quiet -export-fixes $FIXES_FILE $* $REGEX"
|
2018-05-07 01:07:34 +08:00
|
|
|
|
2020-05-15 06:15:35 +08:00
|
|
|
# Generate the compilation database
|
2018-05-07 01:07:34 +08:00
|
|
|
mkdir -p tidy-build
|
|
|
|
cd tidy-build
|
2020-05-17 03:59:10 +08:00
|
|
|
|
|
|
|
# Disable precompiled headers since they aren't generated during linting which causes an error
|
|
|
|
# Disable unity builds since clang-tidy needs the full list of compiled files to check each one
|
2020-05-22 06:52:19 +08:00
|
|
|
cmake --target Cuberite -DCMAKE_EXPORT_COMPILE_COMMANDS=Yes -DPRECOMPILE_HEADERS=No -DUNITY_BUILDS=No ..
|
2018-05-07 01:07:34 +08:00
|
|
|
|
2020-05-15 06:15:35 +08:00
|
|
|
# Ensure LuaState_Typedefs.inc has been generated
|
|
|
|
(cd ../src/Bindings && lua BindingsProcessor.lua)
|
|
|
|
|
2020-05-09 03:18:51 +08:00
|
|
|
if run-clang-tidy $ARGS; then
|
2018-05-07 01:07:34 +08:00
|
|
|
echo "clang-tidy: No violations found"
|
|
|
|
else
|
|
|
|
echo "clang-tidy: Found violations"
|
|
|
|
exit 1
|
|
|
|
fi
|