Skip to content

Commit e01888f

Browse files
committed
Fix Coverity Scan build target
When PR #1271 was merged (commit c34c8db), it: 1. Created a new coverity-build target in src/Makefile 2. Updated .github/workflows/coverity.yml to call make coverity-build 3. Forgot to add coverity-build as an explicit target in the top-level Makefile This commit also simplifies src/Makfile a lot for readability. Signed-off-by: Joachim Wiberg <[email protected]>
1 parent cb78723 commit e01888f

File tree

3 files changed

+32
-92
lines changed

3 files changed

+32
-92
lines changed

.github/workflows/coverity.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
- name: Build applications for Coverity
7373
run: |
7474
export PATH=`pwd`/coverity/bin:$PATH
75-
cov-build --dir cov-int make coverity-build
75+
cov-build --dir cov-int make coverity
7676
7777
- name: Submit results to Coverity Scan
7878
env:

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ bmake = $(MAKE) -C buildroot O=$(O) $1
1616
all: $(config) buildroot/Makefile
1717
@+$(call bmake,$@)
1818

19-
check dep:
20-
@echo "Starting local check, stage $@ ..."
19+
check dep coverity:
2120
@make -C src $@
2221

2322
$(config):
@@ -40,4 +39,4 @@ test:
4039
buildroot/Makefile:
4140
@git submodule update --init
4241

43-
.PHONY: all check test
42+
.PHONY: all check coverity dep test

src/Makefile

Lines changed: 29 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,58 @@
11
# Host build of critical components, for static analysis
22
#
33
# Available targets:
4-
# build - Build all components (no static analysis)
5-
# check - Run static analysis (auto-detects scan-build or cppcheck)
6-
# scan-build - Run clang static analyzer (preferred)
7-
# cppcheck - Run cppcheck static analyzer (fallback)
8-
# coverity - Show Coverity Scan usage
9-
# coverity-build - Build for Coverity Scan (used by CI)
10-
# dep - Build dependencies only
4+
# build - Build all components (no static analysis)
5+
# check - Run static analysis (auto-detects scan-build or cppcheck)
6+
# coverity - Build for Coverity Scan (used by CI)
7+
# dep - Build dependencies only
118
#
12-
APPS = bin confd factory keyack statd
13-
14-
# Detect available static analysis tools
9+
# Installation (for 'make check'):
10+
# scan-build (recommended):
11+
# Debian/Ubuntu: sudo apt-get install clang-tools
12+
# Fedora/RHEL: sudo dnf install clang-tools-extra
13+
# Alpine: sudo apk add clang-extra-tools
14+
#
15+
# cppcheck (fallback):
16+
# Debian/Ubuntu: sudo apt-get install cppcheck
17+
# Fedora/RHEL: sudo dnf install cppcheck
18+
#
19+
APPS = bin confd factory keyack statd
1520
HAVE_SCANBUILD := $(shell command -v scan-build 2>/dev/null)
1621
HAVE_CPPCHECK := $(shell command -v cppcheck 2>/dev/null)
1722

18-
.PHONY: all
1923
all:
20-
@echo "*** all not supported, only build/check/coverity possible ***"
24+
@echo "Target 'all' not supported, use build/check/coverity instead"
2125
@false
2226

23-
.PHONY: dep
2427
dep:
2528
(cd libsrx && make -f check.mk dep)
2629

27-
# Main build target (renamed from check)
28-
.PHONY: build
2930
build: dep $(APPS)
3031
rm -rf staging
3132

3233
$(APPS): libsrx
3334
(cd $@ && make -f check.mk)
3435

35-
.PHONY: libsrx
3636
libsrx:
3737
(cd $@ && make -f check.mk)
3838

39-
# Static analysis target - auto-detects scan-build or cppcheck
40-
.PHONY: check
41-
check:
39+
# Static analysis - auto-detects scan-build or cppcheck
40+
check: dep
4241
ifdef HAVE_SCANBUILD
43-
@echo "==> Running scan-build (clang static analyzer)"
44-
$(MAKE) scan-build
42+
@rm -rf scan-results
43+
@scan-build -o scan-results --status-bugs $(MAKE) build
44+
@echo "Scan complete. Results in scan-results/"
4545
else ifdef HAVE_CPPCHECK
46-
@echo "==> Running cppcheck (fallback - scan-build not found)"
47-
@echo " For better analysis, install scan-build:"
48-
@echo " Debian/Ubuntu: apt-get install clang-tools"
49-
@echo " Fedora/RHEL: dnf install clang-tools-extra"
50-
@echo ""
51-
$(MAKE) cppcheck
46+
@for app in libsrx $(APPS); do \
47+
(cd $$app && cppcheck --enable=all --suppress=missingIncludeSystem \
48+
--quiet --template=gcc -I../staging/include . 2>&1) || true; \
49+
done
5250
else
53-
@echo "*** ERROR: No static analysis tool found ***"
54-
@echo ""
55-
@echo "Please install scan-build (recommended) or cppcheck:"
56-
@echo " Debian/Ubuntu: sudo apt-get install clang-tools"
57-
@echo " Fedora/RHEL: sudo dnf install clang-tools-extra"
58-
@echo " Alpine: apk add clang-extra-tools"
59-
@echo ""
60-
@echo "Or install cppcheck as fallback:"
61-
@echo " Debian/Ubuntu: sudo apt-get install cppcheck"
62-
@echo " Fedora/RHEL: sudo dnf install cppcheck"
63-
@false
64-
endif
65-
66-
# Clang static analyzer (preferred)
67-
.PHONY: scan-build
68-
scan-build: dep
69-
ifndef HAVE_SCANBUILD
70-
@echo "*** ERROR: scan-build not found ***"
71-
@echo ""
72-
@echo "Install scan-build for better static analysis:"
73-
@echo " Debian/Ubuntu: sudo apt-get install clang-tools"
74-
@echo " Fedora/RHEL: sudo dnf install clang-tools-extra"
75-
@echo " Alpine: apk add clang-extra-tools"
51+
@echo "Error: No static analysis tool found."
7652
@false
7753
endif
78-
@echo "==> Running scan-build on all components"
79-
@rm -rf scan-results
80-
scan-build -o scan-results --status-bugs $(MAKE) _analyze
81-
@echo "==> Scan complete. Results in scan-results/"
82-
83-
# cppcheck static analyzer
84-
.PHONY: cppcheck
85-
cppcheck: dep
86-
ifndef HAVE_CPPCHECK
87-
@echo "*** ERROR: cppcheck not found ***"
88-
@echo ""
89-
@echo "Install cppcheck:"
90-
@echo " Debian/Ubuntu: sudo apt-get install cppcheck"
91-
@echo " Fedora/RHEL: sudo dnf install cppcheck"
92-
@echo ""
93-
@echo "Or use scan-build (recommended) instead:"
94-
@echo " Debian/Ubuntu: sudo apt-get install clang-tools"
95-
@false
96-
endif
97-
@echo "==> Running cppcheck on all components"
98-
@for app in libsrx $(APPS); do \
99-
echo " -> Checking $$app"; \
100-
(cd $$app && cppcheck --enable=all --suppress=missingIncludeSystem \
101-
--quiet --template=gcc -I../staging/include . 2>&1) || true; \
102-
done
103-
@echo "==> cppcheck complete"
104-
105-
# Internal target for scan-build to analyze
106-
.PHONY: _analyze
107-
_analyze: libsrx $(APPS)
108-
rm -rf staging
10954

110-
# Coverity Scan target (for CI)
111-
.PHONY: coverity
112-
coverity:
113-
@echo "==> Building for Coverity Scan"
114-
@echo "Use: cov-build --dir cov-int make coverity-build"
55+
# Coverity Scan (for CI)
56+
coverity: build
11557

116-
.PHONY: coverity-build
117-
coverity-build: build
58+
.PHONY: all dep build libsrx check coverity

0 commit comments

Comments
 (0)