File tree 4 files changed +86
-5
lines changed
4 files changed +86
-5
lines changed Original file line number Diff line number Diff line change
1
+ Checks : '
2
+ *,
3
+ -cert-err58-cpp,
4
+ -cppcoreguidelines-pro-type-union-access,
5
+ -fuchsia-default-arguments,
6
+ -fuchsia-overloaded-operator,
7
+ -fuchsia-statically-constructed-objects,
8
+ -google-readability-todo,
9
+ -hicpp-signed-bitwise
10
+ '
11
+
12
+ WarningsAsErrors : '
13
+ clang-analyzer-*,
14
+ modernize-*,
15
+ performance-*
16
+ '
17
+
18
+ FormatStyle : ' file'
19
+
20
+ CheckOptions :
21
+ - key : readability-magic-numbers.IgnoredIntegerValues
22
+ value : ' 0;1;2;3;4;16;255;1024'
23
+ - key : cppcoreguidelines-readability-magic-numbers.IgnoredIntegerValues
24
+ value : ' 0;1;2;3;4;16;255;1024'
Original file line number Diff line number Diff line change @@ -17,6 +17,13 @@ IF(NOT ARCH MATCHES "i386|x86_64|NATIVE")
17
17
MESSAGE (FATAL_ERROR "ARCH should be one of i386, x86_64, NATIVE" )
18
18
ENDIF ()
19
19
20
+ IF (NOT DEFINED WITH_CLANG_TIDY)
21
+ SET (WITH_CLANG_TIDY "NO" )
22
+ ENDIF ()
23
+ IF (NOT WITH_CLANG_TIDY MATCHES "YES|NO" )
24
+ MESSAGE (FATAL_ERROR "WITH_CLANG_TIDY should be one of YES, NO" )
25
+ ENDIF ()
26
+
20
27
INCLUDE (external/libseccomp.cmake)
21
28
INCLUDE (external/libcap.cmake)
22
29
INCLUDE (external/libtclap.cmake)
@@ -47,6 +54,11 @@ ADD_DEFINITIONS('-DBUILD_KERNEL_RELEASE="${BUILD_KERNEL_RELEASE}"')
47
54
48
55
ENABLE_TESTING ()
49
56
57
+ IF (WITH_CLANG_TIDY STREQUAL "YES" )
58
+ CMAKE_MINIMUM_REQUIRED (VERSION 3.6.3)
59
+ SET (CMAKE_CXX_CLANG_TIDY clang-tidy)
60
+ ENDIF ()
61
+
50
62
IF (NOT DEFINED WITH_DOCS)
51
63
SET (WITH_DOCS "YES" )
52
64
ENDIF ()
Original file line number Diff line number Diff line change @@ -82,3 +82,27 @@ running tests
82
82
To run test suit use 'check' target, e.g in build directory run:
83
83
84
84
make check
85
+
86
+ notes for developers
87
+ --------------------
88
+
89
+ To manually run clang-format on each file run:
90
+
91
+ make clang-format
92
+
93
+ inside build directory.
94
+
95
+ To manually run clang-tidy on each source file run:
96
+
97
+ make clang-tidy
98
+
99
+ or to use automatically fix errors:
100
+
101
+ make clang-tidy-fix
102
+
103
+ inside build directory.
104
+
105
+ There is possibility to enable running clang-tidy automatically during
106
+ compilation on each file (can significantly slow down compilation):
107
+
108
+ -DWITH_CLANG_TIDY=YES
Original file line number Diff line number Diff line change @@ -11,8 +11,29 @@ INSTALL(TARGETS sio2jail DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
11
11
FILE (GLOB_RECURSE all_sources *.cc *.h *.hpp)
12
12
13
13
ADD_CUSTOM_TARGET (
14
- clang-format
15
- COMMAND
16
- clang-format -style=file -i ${all_sources}
17
- WORKING_DIRECTORY
18
- ${CMAKE_CURRENT_SOURCE_DIR} )
14
+ clang-format
15
+ COMMAND
16
+ clang-format -style=file -i ${all_sources}
17
+ WORKING_DIRECTORY
18
+ ${CMAKE_CURRENT_SOURCE_DIR} )
19
+
20
+ SET (clang_tidy_cxx_flags -x;c++;-std=gnu++14)
21
+
22
+ GET_PROPERTY (include_directories DIRECTORY PROPERTY INCLUDE_DIRECTORIES )
23
+ FOREACH (include_directory IN LISTS include_directories )
24
+ SET (clang_tidy_cxx_flags ${clang_tidy_cxx_flags} ;-I${include_directory} )
25
+ ENDFOREACH ()
26
+
27
+ ADD_CUSTOM_TARGET (
28
+ clang-tidy
29
+ COMMAND
30
+ clang-tidy ${sources} -- ${clang_tidy_cxx_flags}
31
+ WORKING_DIRECTORY
32
+ ${CMAKE_CURRENT_SOURCE_DIR} )
33
+
34
+ ADD_CUSTOM_TARGET (
35
+ clang-tidy-fix
36
+ COMMAND
37
+ clang-tidy ${sources} -fix -fix-errors -- ${clang_tidy_cxx_flags}
38
+ WORKING_DIRECTORY
39
+ ${CMAKE_CURRENT_SOURCE_DIR} )
You can’t perform that action at this time.
0 commit comments