-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add tasks to perform C++ linting with clang-format v18. #17
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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" | ||
|
@@ -30,6 +53,20 @@ tasks: | |
lint-tasks.yml \ | ||
Taskfile.yml | ||
|
||
clang-format: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious, is there a future plan to have this task moved into yscope-dev-utils and also have the venv setup task done from there? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hadn't considered it, but yeah, it probably makes sense, especially now that we can specify maps/arrays as arguments to a task. |
||
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: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious since I'm not too familiar with our C++ code conventions, if we're not sticking with
*.hpp
for headers, when do we use*.h
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.hpp
are meant to be C++ headers..h
are meant to be C-compatible headers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, are there cases we need our own C-compatible headers in
src/clp-ffi-js
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I can think of, but this is more of a default setting in case we have them one day. I could see us forgetting about it and then the file doesn't get formatted properly, lol.