[Tarantool-patches] [PATCH 3/4][v2] cmake: introduce 'check' and 'LuaJIT-checkpatch' targets

Sergey Bronnikov estetus at gmail.com
Mon Jul 17 16:34:36 MSK 2023


From: Sergey Bronnikov <sergeyb at tarantool.org>

In Tarantool we use our own fork of checkpatch [2] with additional check
types. It's logical to use it in a LuaJIT development. We don't need
check tags in commit messages like NO_DOC, NO_CHANGELOG, NO_TEST and
others, so to be able to customize command-line options Github Action, provided
by checkpatch repository [3], was added to the repository.

See documentation for used checkpatch in [4].

Patch introduce new CMake targets: LuaJIT-checkpatch, that checks
patches on top of master branch using script checkpatch.pl [1], and
target check, that combines LuaJIT-luacheck and LuaJIT-checkpatch.

1. https://docs.kernel.org/dev-tools/checkpatch.html
2. https://github.com/tarantool/checkpatch
3. https://github.com/tarantool/checkpatch/blob/master/.github/actions/checkpatch/action.yml
4. https://github.com/tarantool/checkpatch/blob/master/doc/checkpatch.rst
---
 test/CMakeLists.txt | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 47296a22..ccbad035 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -42,6 +42,39 @@ else()
   )
 endif()
 
+find_program(CHECKPATCH checkpatch.pl
+             HINTS ${PROJECT_SOURCE_DIR}/checkpatch)
+if(CHECKPATCH)
+  set(MASTER_BRANCH "tarantool/master")
+  add_custom_target(${PROJECT_NAME}-checkpatch)
+  add_custom_command(TARGET ${PROJECT_NAME}-checkpatch
+    COMMENT "Running checkpatch"
+    COMMAND
+      ${CHECKPATCH}
+        --codespell
+        --color=always
+        --git ${MASTER_BRANCH}..HEAD
+        --ignore COMMIT_LOG_LONG_LINE
+        # Requires at least two lines in commit message and this
+        # is annoying.
+        --ignore COMMIT_MESSAGE
+        --ignore NO_CHANGELOG
+        --ignore NO_DOC
+        --ignore NO_TEST
+        --show-types
+    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+  )
+else()
+  add_custom_target(${PROJECT_NAME}-checkpatch)
+  add_custom_command(TARGET ${PROJECT_NAME}-checkpatch
+    COMMENT "`checkpatch.pl' is not found, so ${PROJECT_NAME}-checkpatch target is dummy"
+  )
+endif()
+
+add_custom_target(check
+  DEPENDS ${PROJECT_NAME}-checkpatch ${PROJECT_NAME}-luacheck
+)
+
 set(LUAJIT_TEST_COMMAND "${LUAJIT_TEST_BINARY} -e dofile[[${LUAJIT_TEST_INIT}]]")
 separate_arguments(LUAJIT_TEST_COMMAND)
 
-- 
2.34.1



More information about the Tarantool-patches mailing list