Skip to content

Commit 0ebac1d

Browse files
committed
Add sources section in cmake lint tasks to prevent tasks from running multiple times unnecessarily
1 parent 0ab9fb4 commit 0ebac1d

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

taskfiles/lint-cmake.yaml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,33 @@ version: "3"
33
tasks:
44
cmake-check:
55
desc: "Runs the CMake linters."
6+
sources: &cmake_format_src_files
7+
- "{{.ROOT_DIR}}/**/*.cmake"
8+
- "{{.ROOT_DIR}}/**/*.cmake.in"
9+
- "{{.ROOT_DIR}}/**/CMakeLists.txt"
10+
- "{{.TASKFILE}}"
11+
- exclude: "{{.ROOT_DIR}}/**/build/*"
612
deps:
713
- "venv"
814
cmds:
915
- task: "cmake"
1016
vars:
1117
FLAGS: "--diff --color"
18+
- task: "cmake"
19+
silent: true
20+
vars:
21+
FLAGS: "--check"
1222

1323
cmake-fix:
1424
desc: "Runs the CMake linters and fixes all violations."
25+
sources: *cmake_format_src_files
1526
deps:
1627
- "venv"
1728
cmds:
1829
- task: "cmake"
1930
vars:
2031
FLAGS: "--in-place"
2132

22-
# Lint all CMake files, excluding those located in build directories.
23-
#
24-
# @param {string} FLAGS Options passed into the CMake linter gersemi.
2533
cmake:
2634
internal: true
2735
requires:
@@ -32,9 +40,7 @@ tasks:
3240
- |-
3341
. "{{.G_LINT_VENV_DIR}}/bin/activate"
3442
find . \
35-
-path ./build -prune -o \( \
36-
-name "CMakeLists.txt" -o \
37-
-name "*.cmake" -o \
38-
-name "*.cmake.in" \
39-
\) -print0 | \
40-
xargs -0 --no-run-if-empty gersemi {{.FLAGS}}
43+
-path ./build -prune -o \
44+
\( -iname "CMakeLists.txt" -o -iname "*.cmake" -o -iname "*.cmake.in" \) \
45+
-print0 | \
46+
xargs -0 --no-run-if-empty gersemi {{.FLAGS}}

0 commit comments

Comments
 (0)