Skip to content

Commit a74d528

Browse files
authored
Merge pull request DeusData#2755 from DeusData/codex/ci-cppcheck-parallel
ci: parallelize cppcheck with isolated whole-program analysis
2 parents 619192a + a4ffb2b commit a74d528

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎Makefile.cbm‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ LLVM_BIN := $(shell brew --prefix llvm 2>/dev/null)/bin
13861386
CLANG_TIDY ?= $(shell [ -x "$(LLVM_BIN)/clang-tidy" ] && echo "$(LLVM_BIN)/clang-tidy" || echo clang-tidy)
13871387
CLANG_FORMAT ?= $(shell [ -x "$(LLVM_BIN)/clang-format" ] && echo "$(LLVM_BIN)/clang-format" || echo clang-format)
13881388
CPPCHECK ?= cppcheck
1389+
CPPCHECK_JOBS ?= 2
13891390

13901391
# macOS SDK sysroot (needed for Homebrew LLVM to find system headers)
13911392
SYSROOT = $(shell xcrun --show-sdk-path 2>/dev/null)
@@ -1410,10 +1411,16 @@ lint-tidy:
14101411
lint-tidy-diff:
14111412
@scripts/lint-tidy-diff.sh "$(CLANG_TIDY)" $(LINT_SRCS) -- $(CFLAGS_COMMON) $(SYSROOT_FLAG)
14121413

1413-
# cppcheck: complementary analysis (config in .cppcheck)
1414+
# cppcheck: complementary analysis (config in .cppcheck). A build directory
1415+
# retains whole-program analysis with parallel workers; each run owns its state.
14141416
lint-cppcheck:
14151417
@echo "=== cppcheck ==="
1416-
@$(CPPCHECK) --enable=warning,style,performance,portability \
1418+
@set -e; \
1419+
cppcheck_dir=$$(mktemp -d "$${TMPDIR:-/tmp}/cbm-cppcheck.XXXXXX"); \
1420+
trap 'status=$$?; rm -rf "$$cppcheck_dir" || :; exit "$$status"' EXIT; \
1421+
trap 'exit 129' HUP; trap 'exit 130' INT; trap 'exit 143' TERM; \
1422+
$(CPPCHECK) -j$(CPPCHECK_JOBS) --cppcheck-build-dir="$$cppcheck_dir" \
1423+
--enable=warning,style,performance,portability \
14171424
--std=c11 --language=c \
14181425
--suppressions-list=.cppcheck \
14191426
--error-exitcode=1 \

0 commit comments

Comments
 (0)