Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make clang-tidy work for header only parts that need SIO includes #649

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/scripts/clang-tidy-hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# Thin wrapper around clang-tidy that we need to make sure that we can pass the
# include directories for SIO to clang-tidy as it seems that it's not always
# present in the compile database that is generated by CMake. This is mainly
# necessary for template heavy header only parts that get included and for which
# clang-tidy runs into a clang-diagnostic-error because it cannot find an SIO
# header. We cannot do this in the pre-commit configuration because we cannot do
# any shell expansion there.

# Safe guard against environments where we do not have SIO available. The
# clang-tidy checks will probably fail, but at least we are not getting problems
# with passing garbage as extra arguments
EXTRA_ARGS=""
if which sio-dump > /dev/null 2>&1; then
EXTRA_ARGS="--extra-arg=-I$(realpath $(dirname $(which sio-dump))/../include)"
fi

clang-tidy -warnings-as-errors='*,-clang-diagnostic-deprecated-declarations' -p compile_commands.json $EXTRA_ARGS ${@}
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ repos:
hooks:
- id: clang-tidy
name: clang-tidy
entry: clang-tidy -warnings-as-errors='*,-clang-diagnostic-deprecated-declarations' -p compile_commands.json
entry: .github/scripts/clang-tidy-hook
types: [c++]
exclude: (tests/(datamodel|src|extra_code)/.*(h|cc)|podioVersion.in.h|SIOFrame.*h)
exclude: (tests/(datamodel|src|extra_code)/.*(h|cc)|podioVersion.in.h)
language: system
- id: clang-format
name: clang-format
Expand Down