[clang] f2b17d2 - [clang-format][NFC] Add CMake target clang-format-check-format (#95873)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 21 09:06:29 PDT 2024
Author: Owen Pan
Date: 2024-06-21T09:06:26-07:00
New Revision: f2b17d2582b45dbe83421d29e77cc1d5fdf4e069
URL: https://github.com/llvm/llvm-project/commit/f2b17d2582b45dbe83421d29e77cc1d5fdf4e069
DIFF: https://github.com/llvm/llvm-project/commit/f2b17d2582b45dbe83421d29e77cc1d5fdf4e069.diff
LOG: [clang-format][NFC] Add CMake target clang-format-check-format (#95873)
Adapted from polly-check-format.
Added:
Modified:
clang/lib/Format/CMakeLists.txt
Removed:
################################################################################
diff --git a/clang/lib/Format/CMakeLists.txt b/clang/lib/Format/CMakeLists.txt
index 84a3c136f650a..b787b11ac7b74 100644
--- a/clang/lib/Format/CMakeLists.txt
+++ b/clang/lib/Format/CMakeLists.txt
@@ -29,3 +29,27 @@ add_clang_library(clangFormat
clangToolingCore
clangToolingInclusions
)
+
+file(GLOB_RECURSE files
+ *.cpp
+ *.h
+ ../../include/clang/Format/*.h
+ ../../tools/clang-format/*.cpp
+ ../../unittests/Format/*.cpp
+ ../../unittests/Format/*.h
+ )
+
+set(check_format_depends)
+set(i 0)
+foreach (file IN LISTS files)
+ add_custom_command(OUTPUT clang-format-check-format${i}
+ COMMAND clang-format ${file} |
diff -u ${file} -
+ VERBATIM
+ COMMENT "Checking format of ${file}..."
+ )
+ list(APPEND check_format_depends "clang-format-check-format${i}")
+
+ math(EXPR i ${i}+1)
+endforeach ()
+
+add_custom_target(clang-format-check-format DEPENDS ${check_format_depends})
More information about the cfe-commits
mailing list