Skip to content

Commit

Permalink
taskfiles: Add tasks to run clang-format and clang-tidy. (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
AVMatthews authored Nov 1, 2024
1 parent 159768c commit fe2fb1b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lint-configs/lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Lock to v18.x until we can upgrade our code to meet v19's formatting standards.
clang-format~=18.1
clang-tidy>=19.1.0
yamllint>=1.35.1
38 changes: 38 additions & 0 deletions taskfiles/utils.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,41 @@ tasks:
. "{{.OUTPUT_DIR}}/bin/activate"
pip3 install --upgrade pip
pip3 install --upgrade -r "{{.REQUIREMENTS_FILE}}"
# ===
# C++ LINTING UTILS
# ===

# Runs clang-format on C++ files at the given paths.
#
# @param {string} FLAGS Any flags to pass to clang-format.
# @param {[]string} SRC_PATHS The paths on which to run clang-format.
# @param {string} VENV_DIR Python virtual environment where clang-format is installed.
clang-format:
internal: true
requires:
vars: ["FLAGS", "SRC_PATHS", "VENV_DIR"]
cmd: |-
. "{{.VENV_DIR}}/bin/activate"
find {{- range .SRC_PATHS}} "{{.}}" {{- end}} \
-type f \
\( -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" \) \
-print0 | \
xargs -0 clang-format {{.FLAGS}} -Werror
# Runs clang-tidy on C++ files at the given paths.
#
# @param {string} FLAGS Any flags to pass to clang-tidy.
# @param {[]string} SRC_PATHS The paths on which to run clang-tidy.
# @param {string} VENV_DIR Python virtual environment where clang-tidy is installed.
clang-tidy:
internal: true
requires:
vars: ["FLAGS", "SRC_PATHS", "VENV_DIR"]
cmd: |-
. "{{.VENV_DIR}}/bin/activate"
find {{- range .SRC_PATHS}} "{{.}}" {{- end}} \
-type f \
\( -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" \) \
-print0 | \
xargs -0 clang-tidy {{.FLAGS}}

0 comments on commit fe2fb1b

Please sign in to comment.