Skip to content

Commit 5c3f461

Browse files
ligurioigormunkin
authored andcommitted
cmake: introduce target with codespell
The patch introduces a new CMake target: "LuaJIT-codespell", that spellchecks files specified in the whitelist by codespell [1]. 1. https://github.com/codespell-project/codespell Reviewed-by: Maxim Kokryashkin <[email protected]> Reviewed-by: Sergey Kaplun <[email protected]> Signed-off-by: Igor Munkin <[email protected]>
1 parent 2780def commit 5c3f461

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

.codespell-ignore-words.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
isnt
2+
fpr

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
3232
include(LuaJITUtils)
3333
include(SetBuildParallelLevel)
3434
include(SetVersion)
35+
include(CodeSpell)
3536

3637
# --- Variables to be exported to child scopes ---------------------------------
3738

cmake/CodeSpell.cmake

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
find_program(CODESPELL codespell)
2+
3+
set(CODESPELL_WHITELIST
4+
${PROJECT_SOURCE_DIR}/.flake8rc
5+
${PROJECT_SOURCE_DIR}/.github
6+
${PROJECT_SOURCE_DIR}/.luacheckrc
7+
${PROJECT_SOURCE_DIR}/CMakeLists.txt
8+
${PROJECT_SOURCE_DIR}/cmake
9+
${PROJECT_SOURCE_DIR}/src/CMakeLists.txt
10+
${PROJECT_SOURCE_DIR}/src/lib_misc.c
11+
${PROJECT_SOURCE_DIR}/src/lj_mapi.c
12+
${PROJECT_SOURCE_DIR}/src/lj_memprof.c
13+
${PROJECT_SOURCE_DIR}/src/lj_memprof.h
14+
${PROJECT_SOURCE_DIR}/src/lj_symtab.c
15+
${PROJECT_SOURCE_DIR}/src/lj_symtab.h
16+
${PROJECT_SOURCE_DIR}/src/lj_sysprof.c
17+
${PROJECT_SOURCE_DIR}/src/lj_sysprof.h
18+
${PROJECT_SOURCE_DIR}/src/lj_utils.h
19+
${PROJECT_SOURCE_DIR}/src/lj_utils_leb128.c
20+
${PROJECT_SOURCE_DIR}/src/lj_wbuf.c
21+
${PROJECT_SOURCE_DIR}/src/lj_wbuf.h
22+
${PROJECT_SOURCE_DIR}/src/lmisclib.h
23+
${PROJECT_SOURCE_DIR}/src/luajit-gdb.py
24+
${PROJECT_SOURCE_DIR}/src/luajit_lldb.py
25+
${PROJECT_SOURCE_DIR}/test/CMakeLists.txt
26+
${PROJECT_SOURCE_DIR}/test/LuaJIT-tests/CMakeLists.txt
27+
${PROJECT_SOURCE_DIR}/test/PUC-Rio-Lua-5.1-tests/CMakeLists.txt
28+
${PROJECT_SOURCE_DIR}/test/PUC-Rio-Lua-5.1-tests/CMakeLists.txt
29+
${PROJECT_SOURCE_DIR}/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
30+
${PROJECT_SOURCE_DIR}/test/lua-Harness-tests/CMakeLists.txt
31+
${PROJECT_SOURCE_DIR}/test/tarantool-c-tests
32+
${PROJECT_SOURCE_DIR}/test/tarantool-tests
33+
${PROJECT_SOURCE_DIR}/tools
34+
)
35+
36+
set(IGNORE_WORDS ${PROJECT_SOURCE_DIR}/.codespell-ignore-words.txt)
37+
38+
add_custom_target(${PROJECT_NAME}-codespell)
39+
if(CODESPELL)
40+
add_custom_command(TARGET ${PROJECT_NAME}-codespell
41+
COMMENT "Running codespell"
42+
COMMAND
43+
${CODESPELL}
44+
--ignore-words ${IGNORE_WORDS}
45+
--skip ${IGNORE_WORDS}
46+
--check-filenames
47+
${CODESPELL_WHITELIST}
48+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
49+
)
50+
else()
51+
set(STR1 "codespell is not found,")
52+
set(STR2 "so ${PROJECT_NAME}-codespell target is dummy")
53+
string(CONCAT WARN_MSG "${STR1} ${STR2}")
54+
add_custom_command(TARGET ${PROJECT_NAME}-codespell
55+
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red ${WARN_MSG}
56+
COMMENT ${WARN_MSG}
57+
)
58+
endif()

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ endif()
6868
add_custom_target(${PROJECT_NAME}-lint DEPENDS
6969
${PROJECT_NAME}-luacheck
7070
${PROJECT_NAME}-flake8
71+
${PROJECT_NAME}-codespell
7172
)
7273

7374
set(LUAJIT_TEST_COMMAND "${LUAJIT_TEST_BINARY} -e dofile[[${LUAJIT_TEST_INIT}]]")

0 commit comments

Comments
 (0)