Skip to content

Commit

Permalink
Add tasks to perform C++ linting with clang-format v18. (#17)
Browse files Browse the repository at this point in the history
Co-authored-by: Junhao Liao <[email protected]>
  • Loading branch information
kirkrodrigues and junhaoliao authored Oct 5, 2024
1 parent be24868 commit 3457e37
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Lock to v18.x until we can upgrade our code to meet v19's formatting standards.
clang-format~=18.1
yamllint>=1.35.1
37 changes: 37 additions & 0 deletions lint-tasks.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,43 @@
version: "3"

vars:
G_SRC_CLP_FFI_JS_DIR: "{{.ROOT_DIR}}/src/clp_ffi_js"
G_LINT_VENV_DIR: "{{.G_BUILD_DIR}}/lint-venv"

tasks:
check:
cmds:
- task: "cpp-check"
- task: "yml-check"

fix:
cmds:
- task: "cpp-fix"
- task: "yml-fix"

cpp-configs:
cmd: "{{.ROOT_DIR}}/tools/yscope-dev-utils/lint-configs/symlink-cpp-lint-configs.sh"

cpp-check:
sources: &cpp_source_files
- "{{.G_SRC_CLP_FFI_JS_DIR}}/.clang-format"
- "{{.G_SRC_CLP_FFI_JS_DIR}}/**/*.cpp"
- "{{.G_SRC_CLP_FFI_JS_DIR}}/**/*.h"
- "{{.G_SRC_CLP_FFI_JS_DIR}}/**/*.hpp"
- "{{.TASKFILE}}"
- "tools/yscope-dev-utils/lint-configs/.clang-format"
cmds:
- task: "clang-format"
vars:
FLAGS: "--dry-run"

cpp-fix:
sources: *cpp_source_files
cmds:
- task: "clang-format"
vars:
FLAGS: "-i"

yml:
aliases:
- "yml-check"
Expand All @@ -30,6 +53,20 @@ tasks:
lint-tasks.yml \
Taskfile.yml
clang-format:
internal: true
requires:
vars: ["FLAGS"]
deps: ["cpp-configs", "venv"]
cmds:
- |-
. "{{.G_LINT_VENV_DIR}}/bin/activate"
find "{{.G_SRC_CLP_FFI_JS_DIR}}" \
-type f \
\( -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" \) \
-print0 | \
xargs -0 clang-format {{.FLAGS}} -Werror
venv:
internal: true
vars:
Expand Down

0 comments on commit 3457e37

Please sign in to comment.