aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorIvan Komissarov <ABBAPOH@gmail.com>2019-11-24 22:17:15 +0100
committerIvan Komissarov <ABBAPOH@gmail.com>2019-12-05 15:51:00 +0000
commit5b124352feb959f0e4370bdeaa4b6b95d068610d (patch)
tree2ed6f4224982b5786ebce8e8e30b22828c6c0974 /scripts
parente7ee801c5a7b9b46115c708b906875ad887566cf (diff)
Enable clang-tidy job on Travis
This runs predefined clang-tidy checks on the QBS sources, excluding examples and tests Most checks are displayed as warings, however, some checks are treated as errors to avoid adding regressions in the new code clang-analyzer-* checks are not enabled due to performance reasons (otherwise, Travis job hits 50 min) Change-Id: I686003d2526a11d90fc74c88104b4357d67620d1 Reviewed-by: Richard Weickelt <richard@weickelt.de> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/run-analyzer.sh39
1 files changed, 35 insertions, 4 deletions
diff --git a/scripts/run-analyzer.sh b/scripts/run-analyzer.sh
index e3743f631..7f437ac04 100755
--- a/scripts/run-analyzer.sh
+++ b/scripts/run-analyzer.sh
@@ -38,8 +38,6 @@
##
#############################################################################
-set -e
-
LLVM_INSTALL_DIR=${LLVM_INSTALL_DIR:-""}
# on Debian, it might be necessary to setup which version of clang-tidy and run-clang-tidy.py
@@ -59,10 +57,22 @@ if [ -z "$RUN_CLANG_TIDY" ] || [ -z "$CLANG_TIDY" ]; then
fi
fi
+NPROC=`which nproc`
+SYSCTL=`which sysctl`
+CPU_COUNT=2
+if [ ! -z "$NPROC" ]; then # Linux
+ CPU_COUNT=`$NPROC --all`
+elif [ ! -z "$SYSCTL" ]; then # macOS
+ CPU_COUNT=`$SYSCTL -n hw.ncpu`
+fi
+
BUILD_OPTIONS="\
${QBS_BUILD_PROFILE:+profile:${QBS_BUILD_PROFILE}} \
modules.qbsbuildconfig.enableProjectFileUpdates:true \
- modules.qbsbuildconfig.enableUnitTests:true \
+ modules.cpp.treatWarningsAsErrors:true \
+ modules.qbs.buildVariant:release \
+ project.withTests:false \
+ ${BUILD_OPTIONS} \
config:analyzer
"
@@ -73,8 +83,29 @@ if [ ! -f "$QBS_SRC_DIR/qbs.qbs" ]; then
exit 1
fi
+set -e
+
qbs resolve -f "$QBS_SRC_DIR/qbs.qbs" $BUILD_OPTIONS
qbs build -f "$QBS_SRC_DIR/qbs.qbs" $BUILD_OPTIONS
qbs generate -g clangdb -f "$QBS_SRC_DIR/qbs.qbs" $BUILD_OPTIONS
-"$RUN_CLANG_TIDY" -p analyzer -clang-tidy-binary "$CLANG_TIDY" -header-filter=".*qbs.*\.h"
+SCRIPT="
+import json
+import os
+import sys
+
+file = sys.argv[1]
+blacklist = ['json.cpp']
+patched_db = []
+with open(file, 'r') as f:
+ db = json.load(f)
+ for item in db:
+ if os.path.basename(item['file']) not in blacklist:
+ patched_db.append(item)
+
+with open(file, 'w') as f:
+ f.write(json.dumps(patched_db, indent=2))
+"
+python -c "${SCRIPT}" analyzer/compile_commands.json
+
+"$RUN_CLANG_TIDY" -p analyzer -clang-tidy-binary "$CLANG_TIDY" -j $CPU_COUNT -header-filter=".*qbs.*\.h" -quiet