diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index 71a444b..70718dd 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -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/convert-to-sarif@v1.0.3 with: tool: 'CppCheck' - input_file: 'cppcheck.xml' + input_file: 'build/cppcheck.xml' sarif_file: 'cppcheck.sarif' - name: define CONTAINER_WORKSPACE run: | diff --git a/meson.build b/meson.build index 2a735b4..34cf2b4 100644 --- a/meson.build +++ b/meson.build @@ -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')]) diff --git a/support/cppcheck-wrapper.sh b/support/cppcheck-wrapper.sh new file mode 100755 index 0000000..b56396d --- /dev/null +++ b/support/cppcheck-wrapper.sh @@ -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 \ + "$@"