Skip to content

Commit

Permalink
Integrate Cppcheck into Meson build
Browse files Browse the repository at this point in the history
This simplifies the analysis workflow, and makes it easier to
(re-)produce reports locally.
  • Loading branch information
airtower-luna committed Oct 17, 2024
1 parent 1f113db commit 8ce3f54
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,13 @@ jobs:
run: ln -s meson.options meson_options.txt
- name: meson setup
run: meson setup -Dpdf-doc=false build
- name: meson compile
run: meson compile -C build/
- name: cppcheck
run: |
cppcheck --project=build/compile_commands.json -DAF_UNIX=1 --enable=warning,style,unusedFunction --xml 2>cppcheck.xml
ninja -C build/ cppcheck-xml
- uses: airtower-luna/[email protected]
with:
tool: 'CppCheck'
input_file: 'cppcheck.xml'
input_file: 'build/cppcheck.xml'
sarif_file: 'cppcheck.sarif'
- name: define CONTAINER_WORKSPACE
run: |
Expand Down
9 changes: 9 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,12 @@ subdir('include')
subdir('src')
subdir('doc')
subdir('test')

run_target(
'cppcheck',
command: ['support/cppcheck-wrapper.sh'])

run_target(
'cppcheck-xml',
command: ['support/cppcheck-wrapper.sh', '--xml',
'--output-file=' + join_paths(meson.build_root(), 'cppcheck.xml')])
11 changes: 11 additions & 0 deletions support/cppcheck-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# run cppcheck using the project config created by Meson, write output
# to build dir
CPPCHECK_DIR="${MESON_BUILD_ROOT}/cppcheck"
mkdir -p "${CPPCHECK_DIR}"
cppcheck --project="${MESON_BUILD_ROOT}/compile_commands.json" \
--cppcheck-build-dir="${CPPCHECK_DIR}" \
-DAF_UNIX=1 \
--enable=warning,style \
--check-level=exhaustive \
"$@"

0 comments on commit 8ce3f54

Please sign in to comment.