-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint.cmake
More file actions
32 lines (30 loc) · 975 Bytes
/
lint.cmake
File metadata and controls
32 lines (30 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
file(GLOB_RECURSE files_to_format
${CMAKE_CURRENT_LIST_DIR}/include/*.h
${CMAKE_CURRENT_LIST_DIR}/include/zephyr/*.h
${CMAKE_CURRENT_LIST_DIR}/include/ic_macros/*.h
${CMAKE_CURRENT_LIST_DIR}/tests/*.c
${CMAKE_CURRENT_LIST_DIR}/tests/*.h
${CMAKE_CURRENT_LIST_DIR}/src/*.c
)
if("${CMAKE_ARGV3}" STREQUAL "format")
message("Running clang-format-18 in-place")
foreach(file ${files_to_format})
execute_process(
COMMAND clang-format-18 "-i" "${file}"
RESULT_VARIABLE res
)
if(NOT ${res} STREQUAL "0")
message(FATAL_ERROR "clang-format-18 error")
endif()
endforeach()
endif()
foreach(file ${files_to_format})
execute_process(
COMMAND clang-format-18 "--dry-run" "--Werror" "${file}"
RESULT_VARIABLE res
)
if(NOT ${res} STREQUAL "0")
message(FATAL_ERROR "clang-format-18 error")
endif()
endforeach()
message("clang-format-18 passed")