-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqa-check.sh
More file actions
executable file
·43 lines (35 loc) · 1.33 KB
/
qa-check.sh
File metadata and controls
executable file
·43 lines (35 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="${ROOT_DIR}/build-ninja"
echo "== Configure =="
cmake -S "${ROOT_DIR}" -B "${BUILD_DIR}" -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
echo "== Build =="
cmake --build "${BUILD_DIR}"
echo "== cppcheck =="
cppcheck --enable=warning,style,performance,portability --std=c++17 --language=c++ --inline-suppr --quiet "${ROOT_DIR}/src/main.cpp"
echo "== clang-tidy =="
clang-tidy "${ROOT_DIR}/src/main.cpp" \
-p "${BUILD_DIR}" \
--removed-arg=-mno-direct-extern-access \
-checks='clang-analyzer-*,bugprone-*,performance-*' \
--quiet
echo "== clazy =="
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "${TMP_DIR}"' EXIT
python - "${BUILD_DIR}/compile_commands.json" "${TMP_DIR}/compile_commands.json" <<'PY'
import json
import sys
src, dst = sys.argv[1], sys.argv[2]
with open(src, "r", encoding="utf-8") as f:
data = json.load(f)
for item in data:
if "command" in item:
item["command"] = item["command"].replace(" -mno-direct-extern-access", "")
if "arguments" in item:
item["arguments"] = [arg for arg in item["arguments"] if arg != "-mno-direct-extern-access"]
with open(dst, "w", encoding="utf-8") as f:
json.dump(data, f)
PY
clazy-standalone "${ROOT_DIR}/src/main.cpp" -p "${TMP_DIR}"
echo "== Quality checks complete. =="