diff --git a/lint-requirements.txt b/lint-requirements.txt index 993e8b4f..0d86af9a 100644 --- a/lint-requirements.txt +++ b/lint-requirements.txt @@ -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 diff --git a/lint-tasks.yml b/lint-tasks.yml index e5ef8100..c474b9f1 100644 --- a/lint-tasks.yml +++ b/lint-tasks.yml @@ -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" @@ -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: